結果

問題 No.1617 Palindrome Removal
ユーザー neterukunneterukun
提出日時 2021-07-22 21:42:48
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 324 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 86,720 KB
実行使用メモリ 102,500 KB
最終ジャッジ日時 2023-09-24 16:14:40
合計ジャッジ時間 4,615 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
101,572 KB
testcase_01 AC 111 ms
94,648 KB
testcase_02 AC 123 ms
101,868 KB
testcase_03 AC 124 ms
101,684 KB
testcase_04 AC 124 ms
102,500 KB
testcase_05 AC 120 ms
99,804 KB
testcase_06 AC 80 ms
74,984 KB
testcase_07 AC 77 ms
73,336 KB
testcase_08 AC 72 ms
71,020 KB
testcase_09 AC 71 ms
71,036 KB
testcase_10 AC 129 ms
101,424 KB
testcase_11 AC 94 ms
80,340 KB
testcase_12 AC 115 ms
94,684 KB
testcase_13 AC 113 ms
94,672 KB
testcase_14 AC 72 ms
71,152 KB
testcase_15 AC 72 ms
71,352 KB
testcase_16 AC 72 ms
71,240 KB
testcase_17 AC 71 ms
71,200 KB
testcase_18 AC 73 ms
71,340 KB
testcase_19 AC 73 ms
71,328 KB
testcase_20 AC 71 ms
71,252 KB
testcase_21 AC 72 ms
71,112 KB
testcase_22 AC 72 ms
71,200 KB
testcase_23 AC 72 ms
71,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
n = len(s)


a = s[0 : n // 2]
b = s[(n + 1) // 2 : n][::-1]

if a != b:
    print(n)
    exit()

if n % 2 == 0:
    if len(set(list(a))) == 1:
        print(0)
    else:
        print(n - 2)
else:
    if len(set(list(s))) == 1:
        print(-1)
    elif n == 3:
        print(-1)
    else:
        print(n - 2)
0