結果

問題 No.1617 Palindrome Removal
ユーザー m1k__m1k__
提出日時 2021-07-22 21:43:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 316 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 78,052 KB
最終ジャッジ日時 2023-09-24 16:16:00
合計ジャッジ時間 3,595 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
77,656 KB
testcase_01 AC 82 ms
77,728 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 92 ms
78,036 KB
testcase_05 AC 87 ms
77,700 KB
testcase_06 AC 96 ms
78,052 KB
testcase_07 AC 89 ms
77,400 KB
testcase_08 AC 73 ms
71,328 KB
testcase_09 AC 71 ms
71,320 KB
testcase_10 AC 92 ms
77,772 KB
testcase_11 AC 90 ms
77,456 KB
testcase_12 AC 93 ms
78,004 KB
testcase_13 AC 92 ms
77,936 KB
testcase_14 AC 73 ms
71,168 KB
testcase_15 AC 71 ms
71,076 KB
testcase_16 AC 71 ms
71,072 KB
testcase_17 AC 72 ms
71,232 KB
testcase_18 AC 72 ms
71,200 KB
testcase_19 AC 73 ms
71,128 KB
testcase_20 AC 72 ms
71,188 KB
testcase_21 AC 72 ms
71,156 KB
testcase_22 AC 71 ms
70,976 KB
testcase_23 AC 71 ms
71,108 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)<=1:
        print(-1 if lenS%2 else 0)
    else:
        print(lenS-2)
else:
    print(lenS)
0