結果

問題 No.1617 Palindrome Removal
ユーザー 👑 tamatotamato
提出日時 2021-07-22 21:25:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 1,660 ms
コンパイル使用メモリ 87,380 KB
実行使用メモリ 95,752 KB
最終ジャッジ日時 2023-09-24 15:30:37
合計ジャッジ時間 4,073 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
94,020 KB
testcase_01 AC 113 ms
94,836 KB
testcase_02 AC 120 ms
95,476 KB
testcase_03 AC 122 ms
95,028 KB
testcase_04 AC 123 ms
95,628 KB
testcase_05 AC 116 ms
94,180 KB
testcase_06 AC 128 ms
95,628 KB
testcase_07 AC 112 ms
92,796 KB
testcase_08 AC 70 ms
71,648 KB
testcase_09 AC 70 ms
71,504 KB
testcase_10 AC 122 ms
94,860 KB
testcase_11 AC 124 ms
93,976 KB
testcase_12 AC 132 ms
95,700 KB
testcase_13 AC 132 ms
95,752 KB
testcase_14 AC 70 ms
71,728 KB
testcase_15 AC 73 ms
71,816 KB
testcase_16 AC 73 ms
71,348 KB
testcase_17 AC 72 ms
71,684 KB
testcase_18 AC 71 ms
71,648 KB
testcase_19 AC 73 ms
71,292 KB
testcase_20 AC 75 ms
71,292 KB
testcase_21 AC 73 ms
71,652 KB
testcase_22 AC 73 ms
71,736 KB
testcase_23 AC 72 ms
71,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')

    if len(set(S)) == 1:
        if len(S) & 1:
            print(-1)
        else:
            print(0)
        exit()

    if len(S) & 1:
        if S != S[::-1]:
            print(len(S))
        else:
            if len(S) == 3:
                print(-1)
            else:
                print(len(S) - 2)
    else:
        if S == S[::-1]:
            print(len(S) - 2)
        else:
            print(len(S))


if __name__ == '__main__':
    main()
0