結果

問題 No.1617 Palindrome Removal
ユーザー rlangevin
提出日時 2023-01-09 15:05:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 338 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 106,344 KB
最終ジャッジ日時 2024-12-17 18:41:07
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

S = list(input())
N = len(S)
left, right = 0, N - 1
while left < right:
    if S[left] != S[right]:
        print(N)
        exit()
    left += 1
    right -= 1
if len(set(S)) == 1:
    if len(S) % 2:
        print(-1)
    else:
        print(0)
else:
    if len(S) == 3 and S[0] == S[-1]:
        print(-1)
    else:
        print(N - 2)
0