結果

問題 No.1617 Palindrome Removal
ユーザー m1k__m1k__
提出日時 2021-07-22 21:57:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 369 bytes
コンパイル時間 1,541 ms
コンパイル使用メモリ 86,224 KB
実行使用メモリ 77,956 KB
最終ジャッジ日時 2023-09-24 16:49:26
合計ジャッジ時間 5,178 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
77,224 KB
testcase_01 AC 88 ms
77,720 KB
testcase_02 AC 87 ms
77,400 KB
testcase_03 AC 85 ms
77,224 KB
testcase_04 AC 97 ms
77,956 KB
testcase_05 AC 93 ms
77,312 KB
testcase_06 AC 96 ms
77,736 KB
testcase_07 AC 91 ms
77,048 KB
testcase_08 AC 75 ms
70,804 KB
testcase_09 AC 75 ms
70,916 KB
testcase_10 AC 93 ms
77,680 KB
testcase_11 AC 92 ms
77,412 KB
testcase_12 AC 96 ms
77,892 KB
testcase_13 AC 97 ms
77,660 KB
testcase_14 AC 73 ms
70,768 KB
testcase_15 AC 74 ms
70,912 KB
testcase_16 AC 72 ms
70,952 KB
testcase_17 AC 74 ms
70,952 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 73 ms
71,104 KB
testcase_21 AC 75 ms
70,956 KB
testcase_22 AC 73 ms
70,916 KB
testcase_23 AC 73 ms
70,804 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 lenS%2:
    s = S[lenS//2]
    cnt[ord(s)-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