No.273 Palindrome Decomposition
タグ : / 解いたユーザー数 313
作問者 :
nmnmnmnmnmnmnm
Problem Statement
You are given a string $S$.
Cut the string $S$ freely at positions between characters to decompose it into two or more palindromes.
You must always cut at at least one position.
Find the length of the longest palindrome string obtained in this way.
Input
$S$
The string $S$ is given. $2\le $length of the string $S$$ \le 50$.
All characters of the string $S$ are uppercase letters of the alphabet.
Output
Output on one line the number of characters of the longest palindrome after the decomposition.
Do not forget the newline at the end.
Sample
Sample 1
Input
ABACDDCEFGFE
Output
5
For example, it can be decomposed into the three palindromes "ABA", "CDDC", and "EFGFE".
The longest palindrome is "EFGFE", which has 5 characters.
Sample 2
Input
ZZ
Output
1
"ZZ" is already a palindrome, but it must be decomposed into two or more palindromes.
A single character "Z" also counts as a palindrome, so it can be decomposed into "Z" and "Z", and the number of characters is 1.
Sample 3
Input
AABAAABBABBABBBAAABAA
Output
8
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。