結果

問題 No.588 空白と回文
コンテスト
ユーザー lloyz
提出日時 2022-08-28 09:44:10
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 395 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 368 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 77,952 KB
最終ジャッジ日時 2026-05-04 00:49:09
合計ジャッジ時間 7,805 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

S = input()

n = len(S)
ans = 1
for i in range(n):
    j = 1
    res = 1
    while i - j >= 0 and i + j < n:
        if S[i - j] == S[i + j]:
            res += 2
        j += 1
    ans = max(ans, res)
for i in range(n - 1):
    j = 0
    res = 0
    while i - j >= 0 and i + j + 1 < n:
        if S[i - j] == S[i + j + 1]:
            res += 2
        j += 1
    ans = max(ans, res)
print(ans)
0