#P4287. Longest Double Palindromic Substring
Longest Double Palindromic Substring
Longest Double Palindromic Substring
Let the reverse of a string \(w\) be denoted as \(w^{\mathsf{R}}\). For example, \((abcd)^{\mathsf{R}} = dcba\) and \((abba)^{\mathsf{R}} = abba\).
A string \(x\) is called a palindrome if \(x = x^{\mathsf{R}}\). For example, "abba" is a palindrome, while "abed" is not.
A string \(x\) is called a double palindrome if it can be written in the form \[ ww^{\mathsf{R}}ww^{\mathsf{R}} \] In other words, \(x\) must have a length that is a multiple of 4, and \(x\), its first half, and its second half are all palindromes.
A substring of \(x\) is a contiguous sequence of characters in \(x\). A palindromic substring is a substring of \(x\) that is a palindrome, and a double palindromic substring is one that is a double palindrome.
Your task is to compute the length of the longest double palindromic substring in the given string. If no such substring exists, output 0.
inputFormat
The input consists of a single line containing the string \(s\). The string \(s\) only contains lowercase letters.
outputFormat
Output a single integer: the length of the longest double palindromic substring of \(s\).
sample
abbaabba
8
</p>