CF981A.Antipalindrome
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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…r] ( 1 ≤ l ≤ r ≤ ∣s∣ ) of a string s = s1s2…s∣s∣ is the string slsl + 1…sr .
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?
输入格式
The first line contains a non-empty string s with length at most 50 characters, containing lowercase English letters only.
输出格式
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.
输入输出样例
输入#1
mew
输出#1
3
输入#2
wuffuw
输出#2
5
输入#3
qqqqqqqq
输出#3
0
说明/提示
"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 .