結果

問題 No.1617 Palindrome Removal
ユーザー shotoyooshotoyoo
提出日時 2021-07-22 23:05:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 79,888 KB
最終ジャッジ日時 2023-09-24 18:58:48
合計ジャッジ時間 3,707 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
79,864 KB
testcase_01 AC 103 ms
79,888 KB
testcase_02 AC 94 ms
79,324 KB
testcase_03 AC 94 ms
79,284 KB
testcase_04 AC 86 ms
75,004 KB
testcase_05 AC 83 ms
74,392 KB
testcase_06 AC 87 ms
75,096 KB
testcase_07 AC 79 ms
73,496 KB
testcase_08 AC 72 ms
71,220 KB
testcase_09 AC 72 ms
71,340 KB
testcase_10 AC 84 ms
74,800 KB
testcase_11 AC 81 ms
74,508 KB
testcase_12 AC 86 ms
74,972 KB
testcase_13 AC 87 ms
74,972 KB
testcase_14 AC 73 ms
71,316 KB
testcase_15 AC 72 ms
71,388 KB
testcase_16 AC 73 ms
71,380 KB
testcase_17 AC 71 ms
71,384 KB
testcase_18 AC 75 ms
71,500 KB
testcase_19 AC 74 ms
71,188 KB
testcase_20 AC 74 ms
71,044 KB
testcase_21 AC 75 ms
71,428 KB
testcase_22 AC 74 ms
71,400 KB
testcase_23 AC 75 ms
71,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


s = input()
n = len(s)
if s==s[::-1]:
    if all((s[0]==s[i] for i in range(n))):
        if n%2==0:
            ans = 0
        else:
            ans = -1
    else:
        ans = n-2
else:
    ans = n
if ans==1:
    ans = -1
print(ans)
0