結果

問題 No.1617 Palindrome Removal
ユーザー m1k__m1k__
提出日時 2021-07-22 21:46:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 359 bytes
コンパイル時間 1,299 ms
コンパイル使用メモリ 86,728 KB
実行使用メモリ 78,148 KB
最終ジャッジ日時 2023-09-24 16:22:51
合計ジャッジ時間 4,250 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 86 ms
77,912 KB
testcase_02 AC 84 ms
77,716 KB
testcase_03 AC 85 ms
77,808 KB
testcase_04 AC 95 ms
78,148 KB
testcase_05 AC 92 ms
77,672 KB
testcase_06 AC 99 ms
78,120 KB
testcase_07 AC 89 ms
77,388 KB
testcase_08 AC 74 ms
71,292 KB
testcase_09 AC 73 ms
71,292 KB
testcase_10 AC 93 ms
77,928 KB
testcase_11 AC 92 ms
77,864 KB
testcase_12 AC 92 ms
78,100 KB
testcase_13 AC 93 ms
77,984 KB
testcase_14 AC 74 ms
71,204 KB
testcase_15 AC 73 ms
71,432 KB
testcase_16 AC 72 ms
71,104 KB
testcase_17 AC 73 ms
71,468 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 72 ms
71,392 KB
testcase_21 AC 73 ms
71,232 KB
testcase_22 WA -
testcase_23 AC 72 ms
71,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
cnt = [0]*26
f = 1
lenS = len(S)
for i in range(lenS//2):
    si, sj = S[i], S[lenS-1-i]
    f *= si==sj
    cnt[ord(si)-97] += 1
    cnt[ord(sj)-97] += 1
if f:
    lst = [c for c in cnt if c>0]
    if len(lst)==0:
        print(-1)
    elif len(lst)==1:
        print(lenS-2 if lenS%2 else 0)
    else:
        print(lenS-2)
else:
    print(lenS)
0