#P15520. [CCC 2016 J3] Hidden Palindrome

    ID: 15377 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>字符串2016枚举CCC(加拿大)

[CCC 2016 J3] Hidden Palindrome

Description

A palindrome is a word which is the same when read forwards as it is when read backwards. For example, mom and anna are two palindromes.

A word which has just one letter, such as a, is also a palindrome.

Given a word, what is the longest palindrome that is contained in the word? That is, what is the longest palindrome that we can obtain, if we are allowed to delete characters from the beginning and/or the end of the string?

Input Format

The input will consist of one line, containing a sequence of at least 11 and at most 4040 lowercase letters.

Output Format

Output the total number of letters of the longest palindrome contained in the input word.

banana
5
abracadabra
3
abba
4

Hint

Explanation for Output for Sample Input 1

The palindrome anana has 55 letters.

Explanation for Output for Sample Input 2

The palindromes aca and ada have 33 letters, and there are no other palindromes in the input which are longer.