結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
77,516 KB
testcase_01 AC 84 ms
77,596 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 91 ms
77,896 KB
testcase_05 AC 90 ms
77,320 KB
testcase_06 AC 99 ms
77,864 KB
testcase_07 AC 89 ms
76,984 KB
testcase_08 AC 71 ms
70,716 KB
testcase_09 AC 71 ms
71,192 KB
testcase_10 AC 91 ms
77,752 KB
testcase_11 AC 90 ms
77,328 KB
testcase_12 AC 93 ms
77,868 KB
testcase_13 AC 92 ms
77,892 KB
testcase_14 AC 70 ms
71,096 KB
testcase_15 AC 73 ms
70,844 KB
testcase_16 AC 71 ms
70,840 KB
testcase_17 AC 72 ms
71,112 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 72 ms
71,096 KB
testcase_21 AC 71 ms
71,140 KB
testcase_22 AC 71 ms
70,820 KB
testcase_23 AC 73 ms
70,888 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(0)
        else:
            print(0)
    else:
        print(lenS-2)
else:
    print(lenS)
0