結果

問題 No.1617 Palindrome Removal
ユーザー brthyyjpbrthyyjp
提出日時 2021-07-24 16:22:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 316 bytes
コンパイル時間 499 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 105,988 KB
最終ジャッジ日時 2023-09-27 04:32:24
合計ジャッジ時間 5,015 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
104,908 KB
testcase_01 AC 109 ms
105,736 KB
testcase_02 AC 110 ms
105,520 KB
testcase_03 AC 105 ms
105,208 KB
testcase_04 AC 112 ms
105,988 KB
testcase_05 AC 103 ms
103,152 KB
testcase_06 AC 91 ms
101,128 KB
testcase_07 AC 86 ms
96,276 KB
testcase_08 AC 61 ms
71,400 KB
testcase_09 AC 60 ms
71,276 KB
testcase_10 AC 115 ms
104,956 KB
testcase_11 AC 107 ms
103,304 KB
testcase_12 AC 111 ms
105,724 KB
testcase_13 AC 113 ms
105,828 KB
testcase_14 AC 60 ms
71,124 KB
testcase_15 AC 59 ms
71,396 KB
testcase_16 AC 60 ms
71,116 KB
testcase_17 AC 61 ms
71,124 KB
testcase_18 AC 60 ms
71,396 KB
testcase_19 AC 60 ms
71,404 KB
testcase_20 AC 60 ms
71,416 KB
testcase_21 AC 60 ms
71,124 KB
testcase_22 AC 58 ms
71,472 KB
testcase_23 AC 59 ms
71,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = list(str(input()))
n = len(s)
flag = True
for i in range(n//2):
    if s[i] != s[n-1-i]:
        flag = False
        break
if not flag:
    print(n)
    exit()
if len(set(s)) == 1:
    if n%2 == 1:
        print(-1)
    else:
        print(0)
else:
    if n == 3:
        print(-1)
    else:
        print(n-2)
0