結果

問題 No.1617 Palindrome Removal
ユーザー 330Xs330Xs
提出日時 2022-02-03 14:13:47
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 400 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 146,148 KB
最終ジャッジ日時 2023-09-02 03:17:10
合計ジャッジ時間 5,262 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
137,996 KB
testcase_01 AC 164 ms
146,036 KB
testcase_02 AC 159 ms
137,612 KB
testcase_03 AC 155 ms
137,668 KB
testcase_04 AC 162 ms
146,096 KB
testcase_05 AC 150 ms
128,112 KB
testcase_06 AC 146 ms
145,732 KB
testcase_07 AC 129 ms
115,012 KB
testcase_08 AC 69 ms
71,340 KB
testcase_09 AC 69 ms
71,456 KB
testcase_10 AC 158 ms
137,688 KB
testcase_11 AC 150 ms
127,900 KB
testcase_12 AC 167 ms
145,972 KB
testcase_13 AC 163 ms
146,148 KB
testcase_14 AC 69 ms
71,348 KB
testcase_15 AC 70 ms
71,448 KB
testcase_16 AC 72 ms
71,504 KB
testcase_17 RE -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 71 ms
71,404 KB
testcase_21 AC 71 ms
71,512 KB
testcase_22 AC 72 ms
71,132 KB
testcase_23 AC 72 ms
71,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = list(map(str,input()))
ans = len(s)
elem = set()
flag = True
for i in range(ans//2):
    if(s[i] != s[ans-1-i]):
        flag = False
        break
    else:
        elem.add(s[i])

if(ans % 2 != 0):
    elem.add(s[i+1])
    
if(flag):
    if(len(elem) == 1):
        if(ans % 2 == 0):
            print(0)
        else:
            print(-1)
    else:
        print(ans - 2)
else:
    print(ans)
0