結果

問題 No.1617 Palindrome Removal
ユーザー lloyzlloyz
提出日時 2021-12-02 00:08:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 10,612 KB
実行使用メモリ 10,788 KB
最終ジャッジ日時 2023-09-18 10:05:07
合計ジャッジ時間 1,633 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
10,784 KB
testcase_01 AC 20 ms
9,924 KB
testcase_02 AC 20 ms
9,608 KB
testcase_03 AC 21 ms
10,788 KB
testcase_04 AC 21 ms
9,868 KB
testcase_05 AC 19 ms
10,148 KB
testcase_06 AC 19 ms
9,852 KB
testcase_07 AC 18 ms
9,232 KB
testcase_08 AC 15 ms
7,936 KB
testcase_09 AC 15 ms
7,944 KB
testcase_10 AC 20 ms
10,556 KB
testcase_11 AC 19 ms
9,368 KB
testcase_12 AC 22 ms
10,036 KB
testcase_13 AC 21 ms
9,888 KB
testcase_14 AC 16 ms
7,768 KB
testcase_15 AC 16 ms
7,944 KB
testcase_16 AC 15 ms
7,944 KB
testcase_17 AC 15 ms
7,984 KB
testcase_18 AC 16 ms
8,100 KB
testcase_19 AC 16 ms
7,988 KB
testcase_20 AC 16 ms
7,820 KB
testcase_21 AC 15 ms
7,764 KB
testcase_22 AC 15 ms
7,980 KB
testcase_23 AC 15 ms
7,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
n = len(S)
if S != S[::-1]:
    print(n)
    exit()
if n == 3:
    print(-1)
    exit()

alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for alph in alphabets:
    if S == alph * n:
        if n % 2 == 1:
            print(-1)
        else:
            print(0)
        exit()

print(n - 2)

0