結果

問題 No.1617 Palindrome Removal
ユーザー だれだれ
提出日時 2021-07-06 10:53:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 299 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 86,668 KB
実行使用メモリ 78,152 KB
最終ジャッジ日時 2023-09-24 15:03:20
合計ジャッジ時間 5,227 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
77,800 KB
testcase_01 AC 110 ms
78,152 KB
testcase_02 AC 107 ms
77,876 KB
testcase_03 AC 109 ms
77,836 KB
testcase_04 AC 111 ms
78,028 KB
testcase_05 AC 104 ms
77,544 KB
testcase_06 AC 76 ms
72,992 KB
testcase_07 AC 75 ms
72,316 KB
testcase_08 AC 72 ms
71,176 KB
testcase_09 AC 72 ms
71,384 KB
testcase_10 AC 111 ms
77,852 KB
testcase_11 AC 105 ms
77,724 KB
testcase_12 AC 115 ms
77,980 KB
testcase_13 AC 113 ms
78,112 KB
testcase_14 AC 72 ms
71,180 KB
testcase_15 AC 70 ms
71,124 KB
testcase_16 AC 71 ms
71,168 KB
testcase_17 AC 71 ms
71,172 KB
testcase_18 AC 71 ms
71,244 KB
testcase_19 AC 71 ms
71,260 KB
testcase_20 AC 71 ms
71,148 KB
testcase_21 AC 69 ms
71,188 KB
testcase_22 AC 72 ms
71,356 KB
testcase_23 AC 72 ms
70,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
n = len(s)
assert 1 <= n <= 10 ** 6
u = set()
for i in range(n):
    if s[i] != s[n - i - 1]:
        print(n)
        exit()
    u.add(s[i])

if len(u) == 1:
    if n & 1:
        print(-1)
    else:
        print(0)
else:
    if n == 3:
        print(-1)
    else:
        print(n - 2)
0