結果

問題 No.1617 Palindrome Removal
ユーザー ntudantuda
提出日時 2021-09-05 22:29:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 945 ms
コンパイル使用メモリ 86,336 KB
実行使用メモリ 79,712 KB
最終ジャッジ日時 2023-08-24 05:30:19
合計ジャッジ時間 4,609 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
78,444 KB
testcase_01 AC 148 ms
78,416 KB
testcase_02 AC 154 ms
79,400 KB
testcase_03 AC 155 ms
79,340 KB
testcase_04 AC 153 ms
79,676 KB
testcase_05 AC 146 ms
78,876 KB
testcase_06 AC 161 ms
79,712 KB
testcase_07 AC 133 ms
78,376 KB
testcase_08 AC 92 ms
71,132 KB
testcase_09 AC 93 ms
71,288 KB
testcase_10 AC 149 ms
79,624 KB
testcase_11 AC 154 ms
78,936 KB
testcase_12 AC 160 ms
79,604 KB
testcase_13 AC 164 ms
79,556 KB
testcase_14 AC 96 ms
71,416 KB
testcase_15 AC 92 ms
71,288 KB
testcase_16 AC 93 ms
71,120 KB
testcase_17 AC 96 ms
71,084 KB
testcase_18 AC 93 ms
71,336 KB
testcase_19 AC 95 ms
71,412 KB
testcase_20 AC 93 ms
71,332 KB
testcase_21 AC 95 ms
71,168 KB
testcase_22 AC 91 ms
71,108 KB
testcase_23 AC 92 ms
71,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys

S = input()
D = collections.Counter(S)
ND = len(D)
N = len(S)

if N == 1:
    print(-1)
elif N == 2:
    if ND == 1:
        print(0)
    else:
        print(N)
elif N == 3:
    if S[0] == S[2]:
        print(-1)
    else:
        print(3)
else:
    if ND == 1:
        if N % 2 == 0:
            print(0)
        else:
            print(-1)
    elif S[:N//2] == S[:-(-N//2)-1:-1]:
        print(N-2)
    else:
        print(N)
0