#P4287. [SHOI2011] 双倍回文
[SHOI2011] 双倍回文
Description
Let the reversal of a string be denoted by . For example, , .
For a string , if satisfies , it is called a palindrome. For example, is a palindrome, while is not.
If can be written in the form , it is called a "double palindrome". In other words, for to be a double palindrome, the length of must be a multiple of , and , its first half, and its second half must all be palindromes. For example, is a double palindrome, while is not, because its length is not a multiple of .
- A substring of is a string formed by a consecutive segment of characters in . For example, is a substring of , while is not.
- A palindromic substring of is a substring of that is a palindrome.
- A double palindromic substring of is a substring of that is a double palindrome.
Your task is to compute the length of the longest double palindromic substring of the given string.
Input Format
The input consists of two lines.
- The first line contains an integer , the length of the string.
- The second line contains a string of lowercase English letters, which is the content of the string.
Output Format
Output a single line: the length of the longest double palindromic substring of the input string. If no double palindromic substring exists, output .
16
ggabaabaabaaball
12
Hint
Constraints
For all testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号