Cave Paintings
Time limit1sMemory limit1024 MB
Given a string s, find the length of the longest palindrome that is a substring of some cyclic shift of s.
- Level
Medium6 of 10
- Topics
- String, String matching
- Solved
- No attempts yet
Problem
Doctor Braveston and his group found an ancient cave in Jumanji. A string of lowercase Latin letters was written on its wall. To continue, the explorers must find the length of the longest palindrome that is a substring of some cyclic shift of .
A palindrome is a string that reads the same forward and backward. For example, abacaba, abba, and q are palindromes. A substring is a contiguous run of characters from a string. A cyclic shift is formed by cutting a prefix from the string and appending it to the end. For example, bacabaa, cabaaba, and abacaba are cyclic shifts of abacaba.
Input
The input is a single non-empty line containing the string . The string consists of lowercase Latin letters only, and its length does not exceed .
Output
Print one integer, the maximum length of a palindrome that is a substring of some cyclic shift of .