#P8631. [蓝桥杯 2015 国 AC] 切开字符串
[蓝桥杯 2015 国 AC] 切开字符串
Problem Description
Pear has a string, and he wants to cut it into two parts.
The string has length ().
Pear wants to choose a position and cut the string into two non-overlapping parts without repetition or omission, with lengths and (both parts must be non-empty).
Pear evaluates a cutting plan as follows:
Define an “odd palindrome substring” as a palindrome substring with odd length.
Suppose that in the two resulting substrings, the first part contains distinct odd palindrome substrings, and the second part contains distinct non-odd-palindrome substrings. Then the score of this plan is .
Note that in the second part means “... non-odd-palindrome ...”, not “... odd-palindrome ...”.
Among all cutting plans, what is the maximum value of ?
Input Format
The first line contains a positive integer ().
The next line contains a string of length , consisting only of lowercase English letters.
Output Format
Output one positive integer, representing the maximum value of .
10
bbaaabcaba
38
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
Time limit: 1 second, 512 MB. Lanqiao Cup 2015, 6th National Contest.
Translated by ChatGPT 5