Avito Code Challenge 2018
A
Antipalindrome
Codeforces
900
原题
←B →
翻译中…

A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not.

翻译中…

A substring $s[l \ldots r]$ ($1 \leq l \leq r \leq |s|$) of a string $s = s_{1}s_{2} \ldots s_{|s|}$ is the string $s_{l}s_{l + 1} \ldots s_{r}$.

翻译中…

Anna does not like palindromes, so she makes her friends call her Ann. She also changes all the words she reads in a similar way. Namely, each word $s$ is changed into its longest substring that is not a palindrome. If all the substrings of $s$ are palindromes, she skips the word at all.

翻译中…

Some time ago Ann read the word $s$. What is the word she changed it into?

翻译中…

Input

翻译中…

The first line contains a non-empty string $s$ with length at most $50$ characters, containing lowercase English letters only.

翻译中…

Output

翻译中…

If there is such a substring in $s$ that is not a palindrome, print the maximum length of such a substring. Otherwise print $0$.

翻译中…

Note that there can be multiple longest substrings that are not palindromes, but their length is unique.

翻译中…

Note

翻译中…

"mew" is not a palindrome, so the longest substring of it that is not a palindrome, is the string "mew" itself. Thus, the answer for the first example is $3$.

翻译中…

The string "uffuw" is one of the longest non-palindrome substrings (of length $5$) of the string "wuffuw", so the answer for the second example is $5$.

翻译中…

All substrings of the string "qqqqqqqq" consist of equal characters so they are palindromes. This way, there are no non-palindrome substrings. Thus, the answer for the third example is $0$.

翻译中…

样例

Input #1
mew
Output #1
3
InputCopy OutputCopy
Input #2
wuffuw
Output #2
5
InputCopy OutputCopy
Input #3
qqqqqqqq
Output #3
0
InputCopy OutputCopy
题目信息
题号
981A
时间限制
1 s
内存限制
256 MB
标签
暴力
模拟
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。