#P10915. [蓝桥杯 2024 国 B] 最长回文前后缀
[蓝桥杯 2024 国 B] 最长回文前后缀
Problem Description
Xiaoming especially likes palindromic strings, but palindromic strings are rare. So he defines two non-overlapping prefix and suffix of the same length of a string as a “palindromic prefix-suffix” if and only if concatenating this prefix and suffix forms a palindrome. Then, for a string , the length of the “longest palindromic prefix-suffix” is
where denotes a substring of , and denotes the string obtained by reversing .
For a given string , Xiaoming wants to modify it so that is as large as possible. The modification allows deleting any substring of arbitrary length from the string. For example, after deleting the substring from , becomes .
Xiaoming wants to know: after the modification, what is the maximum possible value of for the new string ?
Input Format
The input consists of line, a string .
Output Format
The output consists of line, an integer representing the answer.
abcdebijbba
3
Hint
Sample Explanation
In the approach described in the statement, after deleting , , and .
Constraints
For of the testdata, .
For of the testdata, , and contains only lowercase letters.
Translated by ChatGPT 5