問題一覧 > 通常問題

No.273 Palindrome Decomposition

レベル : / AI推定難易度 : 189 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 313
作問者 : nmnmnmnmnmnmnm
お気に入りにしたユーザー ProblemId : 389 / 自分の提出
問題文最終更新日: 2026-06-25 09:06:15
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 119 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。