Palindrome
Time limit2sMemory limit128 MB
Find the palindromic substring that maximizes its length times its number of occurrences in the given string.
- Level
Medium7 of 10
- Topics
- String matching, String
- Solved
- No attempts yet
Problem
You are given a string of lowercase letters. The appearance value of a substring is the number of times it occurs in the string multiplied by its length. Write a program that prints the largest appearance value among all palindrome substrings.
Input
The first line contains a string of lowercase letters (a-z). The length is at most 300,000.
Output
Print the largest appearance value among palindrome substrings on one line.
Hint
Let denote the length of string . A substring is a non-empty string with . A palindrome reads the same from left to right and from right to left. A large appearance value can come from a short substring that appears many times or from a long palindrome that appears once.