#abc307b. [abc307_b]racecar
[abc307_b]racecar
Problem Statement
You are given strings consisting of lowercase English letters.
Determine if there are distinct integers and between and , inclusive, such that the concatenation of and in this order is a palindrome.
A string of length is a palindrome if and only if the -th character and the -th character of are the same for every .
Constraints
- is an integer.
- is a string consisting of lowercase English letters.
- All are distinct.
Input
The input is given from Standard Input in the following format:
Output
If there are and that satisfy the condition in the problem statement, print Yes
; otherwise, print No
.
Sample Input 1
5
ab
ccef
da
a
fe
Sample Output 1
Yes
If we take , the concatenation of ab
and a
in this order is aba
, which is a palindrome, satisfying the condition.
Thus, print Yes
.
Here, we can also take , for which the concatenation of fe
and ccef
in this order is feccef
, satisfying the condition.
Sample Input 2
3
a
b
aba
Sample Output 2
No
No two distinct strings among , , and form a palindrome when concatenated. Thus, print No
.
Note that the and in the statement must be distinct.
Sample Input 3
2
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Sample Output 3
Yes