No.588 Spaces and Palindromes
レベル :
/ AI推定難易度 : 650
/ 実行時間制限 : 1ケース 2.000秒 / メモリ制限
: 512 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 169
作問者 :
hirakich1048576
/ テスター :
butsurizuki
タグ : / 解いたユーザー数 169
作問者 :
hirakich1048576
/ テスター :
butsurizuki
問題文最終更新日: 2026-06-26 06:06:58
English (AI translation)
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 176
(順位表)
の他の問題:
Problem Statement
Moriya-chan the ant is abnormally obsessed with line symmetry.
One day, Moriya-chan resolved to eliminate everything in this world that is not line-symmetric.
So, to begin with, she decided to practice an operation that makes a string line-symmetric.
The operation is as follows.
- You are given a string S consisting only of half-width alphanumeric characters.
- Delete some characters of S to make it a line-symmetric string. However, deleting a character does not close the gap (it becomes a space), and deleted characters are not counted in the string length.
- Make the length of the string after the operation as long as possible.
- Assume that there are infinitely many spaces before and after the given string.
- Spaces are not counted in the string length.
a s a
is a "palindrome" and its "character positions are symmetric", so it is line-symmetric, and its length is 3.i l l
has "character positions that are symmetric" but is not a "palindrome", so it is not line-symmetric.ut u
is a "palindrome" but its "character positions are not symmetric", so it is not line-symmetric.
Find the longest possible length of the string after the operation.
Input
S
\( |S| \leq 1000 \)
Output
Output the longest possible length of the string resulting from applying the operation to S.
Sample
Sample 1
Input
chiwawa
Output
3
The longest line-symmetric string contained in "chiwawa" is wbw.
Sample 2
Input
abracadabra
Output
5
Sample 3
Input
1145141919810
Output
5
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。