#P3649. [APIO2014] 回文串
[APIO2014] 回文串
Description
You are given a string consisting of lowercase Latin letters. We define the existence value of a substring of as the number of occurrences of this substring in multiplied by its length.
For the given string , find the maximum existence value among all palindromic substrings.
Input Format
One line, a non-empty string consisting of lowercase Latin letters (a~z).
Output Format
Output a single integer, the maximum existence value among all palindromic substrings.
abacaba
7
www
4
Hint
Sample Explanation 1
Use to denote the length of string .
A substring of a string is a non-empty string , where . Every string is a substring of itself.
A string is called a palindrome if and only if it reads the same from left to right and from right to left.
In this sample, there are palindromic substrings a, b, c, aba, aca, bacab, abacaba. Their existence values are , respectively.
Therefore, the maximum existence value among palindromic substrings is .
Subtasks
- Subtask 1 (8 points): .
- Subtask 2 (15 points): .
- Subtask 3 (24 points): .
- Subtask 4 (26 points): .
- Subtask 5 (27 points): .
Translated by ChatGPT 5
京公网安备 11011102002149号