結果

問題 No.1617 Palindrome Removal
ユーザー neterukun
提出日時 2021-07-22 21:42:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 324 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,248 KB
実行使用メモリ 103,604 KB
最終ジャッジ日時 2024-07-17 17:00:57
合計ジャッジ時間 2,713 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
n = len(s)


a = s[0 : n // 2]
b = s[(n + 1) // 2 : n][::-1]

if a != b:
    print(n)
    exit()

if n % 2 == 0:
    if len(set(list(a))) == 1:
        print(0)
    else:
        print(n - 2)
else:
    if len(set(list(s))) == 1:
        print(-1)
    elif n == 3:
        print(-1)
    else:
        print(n - 2)
0