結果

問題 No.1617 Palindrome Removal
コンテスト
ユーザー puzneko
提出日時 2021-11-11 22:45:36
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 370 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 417 ms
コンパイル使用メモリ 85,632 KB
実行使用メモリ 81,920 KB
最終ジャッジ日時 2026-05-17 13:39:32
合計ジャッジ時間 3,148 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

s = input()
n = len(s)

for i in range(n//2):
    if s[i] != s[-i-1]:
        print("{}".format(n))
        exit()

for i in range(n//2-1):
    if (s[i] != s[-i-3]) | (s[i] != s[-i-2]):
        print("{}".format(n-2))
        exit()
    if (s[i+2] != s[-i-1]) | (s[i+1] != s[-i-1]):
        print("{}".format(n-2))
        exit()

ans = -(n % 2)
print("{}".format(ans))
0