#t112. 回文拼接
回文拼接
Palindrome Concatenation
Problem Description
A string is a palindrome if and only if it reads the same forwards and backwards, e.g. and are palindromes, but is not.
Xiao Yang has strings containing only lowercase letters. He wants you to write a program to determine whether each string can be formed by concatenating two palindromes, each of length at least , front to back.
Input Format
The first line contains a positive integer , representing the number of strings. The next lines each contain one string of lowercase letters only.
Output Format
For each string output one line. If the string can be formed by concatenating two palindromes each of length at least , output Yes; otherwise output No.
Sample Input
4
abcd
aabbb
aaac
abcdd
Sample Output
No
Yes
No
No
Sample Explanation
For the strings in the sample input, check them one by one:
- The first string
abcd: we must split it into a front and a back part, each of length at least . The only possible split isabandcd.abreversed isba, not a palindrome;cdis also not a palindrome. So it does not satisfy the condition, outputNo. - The second string
aabbb: it can be split intoaaandbbb.aareads the same forwards and backwards, so it is a palindrome;bbbalso reads the same, so it is a palindrome. Both parts have length at least , satisfying the condition, outputYes. - The third string
aaac: possible splits areaaandac, oraaaandc. Inaaaandc, the back part has length only , failing the length-at-least- requirement;aais a palindrome butacis not. So it does not satisfy, outputNo. - The fourth string
abcdd: the only length-satisfying splits areabandcdd, orabcanddd.abis not a palindrome; inabcanddd, the front part has length less than . So it does not satisfy, outputNo.
Constraints
For all test data, it is guaranteed that , and the length of each string does not exceed .