結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
77,672 KB
testcase_01 AC 85 ms
77,780 KB
testcase_02 AC 84 ms
77,412 KB
testcase_03 AC 85 ms
77,472 KB
testcase_04 AC 94 ms
77,768 KB
testcase_05 AC 89 ms
77,380 KB
testcase_06 AC 95 ms
77,724 KB
testcase_07 AC 89 ms
76,948 KB
testcase_08 AC 73 ms
70,804 KB
testcase_09 AC 73 ms
70,988 KB
testcase_10 AC 92 ms
77,668 KB
testcase_11 AC 90 ms
77,316 KB
testcase_12 AC 94 ms
77,748 KB
testcase_13 AC 92 ms
77,708 KB
testcase_14 AC 73 ms
71,140 KB
testcase_15 AC 73 ms
71,060 KB
testcase_16 AC 73 ms
71,080 KB
testcase_17 AC 73 ms
70,972 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 73 ms
71,056 KB
testcase_21 AC 73 ms
70,808 KB
testcase_22 AC 71 ms
70,984 KB
testcase_23 AC 72 ms
70,840 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:
        if lenS%2:
            s = S[lenS//2]
            if cnt[ord(s)-97]:
                print(-1)
            else:
                print(lenS-2)
        else:
            print(0)
    else:
        print(lenS-2)
else:
    print(lenS)
0