#B4039. Double Palindrome Concatenation

    ID: 11696 Type: Default 1000ms 256MiB

Double Palindrome Concatenation

Double Palindrome Concatenation

A string is called a palindrome if and only if it reads the same forwards and backwards. For example, \(\texttt{aabaa}\) and \(\texttt{ccddcc}\) are palindromes, while \(\texttt{abcd}\) is not.

Given \(n\) strings consisting only of lowercase letters, determine for each string whether it can be split into two non-empty parts such that:

  • Each of the two parts is a palindrome.
  • Each part has length at least \(2\).

Output YES if such a split exists, and NO otherwise.

inputFormat

The first line contains an integer \(n\) (the number of strings). Each of the following \(n\) lines contains a single string composed of lowercase letters.

outputFormat

For each input string, output a single line containing YES if the string can be partitioned into two palindromic substrings (each of length at least 2), or NO otherwise.

sample

3
abbaabba
abaaba
abcba
YES

YES NO

</p>