logo AlgoBeat OnlineJudge
登录 注册

#215540. [CCC 2016 J3] Hidden Palindrome

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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?

输入格式

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

输出格式

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

样例

样例输入 1

banana

样例输出 1

5

样例输入 2

abracadabra

样例输出 2

3

样例输入 3

abba

样例输出 3

4

数据范围与提示

Explanation for Output for Sample Input 1

The palindrome anana has letters.

Explanation for Output for Sample Input 2

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