結果

問題 No.1617 Palindrome Removal
ユーザー IgrmiIgrmi
提出日時 2021-07-22 21:34:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 280 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 78,016 KB
最終ジャッジ日時 2023-09-24 15:57:57
合計ジャッジ時間 3,342 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
77,744 KB
testcase_01 AC 83 ms
77,604 KB
testcase_02 AC 85 ms
77,444 KB
testcase_03 AC 87 ms
77,396 KB
testcase_04 AC 90 ms
77,772 KB
testcase_05 AC 86 ms
77,520 KB
testcase_06 AC 80 ms
73,260 KB
testcase_07 AC 76 ms
72,312 KB
testcase_08 AC 71 ms
71,060 KB
testcase_09 AC 70 ms
71,312 KB
testcase_10 AC 84 ms
77,656 KB
testcase_11 AC 83 ms
77,424 KB
testcase_12 AC 84 ms
78,016 KB
testcase_13 AC 84 ms
77,964 KB
testcase_14 AC 68 ms
71,172 KB
testcase_15 AC 68 ms
71,124 KB
testcase_16 AC 70 ms
71,312 KB
testcase_17 AC 72 ms
71,176 KB
testcase_18 AC 72 ms
71,324 KB
testcase_19 AC 73 ms
71,048 KB
testcase_20 AC 74 ms
71,408 KB
testcase_21 AC 74 ms
71,344 KB
testcase_22 AC 73 ms
71,296 KB
testcase_23 AC 73 ms
71,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
N = len(S)
Flag = 0
for i in range(N // 2):
    j = N - i - 1
    if S[i] != S[j]:
        print(N)
        exit()
    if S[0] != S[i]: Flag = 1
if Flag: print(N - 2)
elif N % 2 == 0: print(0)
elif S[0] == S[N // 2]: print(-1)
elif N == 3: print(-1)
else: print(N - 2)
0