結果

問題 No.1617 Palindrome Removal
ユーザー mkawa2mkawa2
提出日時 2021-07-22 21:31:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 887 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 11,176 KB
最終ジャッジ日時 2023-09-24 15:50:32
合計ジャッジ時間 3,259 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
11,172 KB
testcase_01 AC 85 ms
10,396 KB
testcase_02 AC 81 ms
10,172 KB
testcase_03 AC 81 ms
11,072 KB
testcase_04 AC 85 ms
10,488 KB
testcase_05 AC 70 ms
10,748 KB
testcase_06 AC 24 ms
10,392 KB
testcase_07 AC 21 ms
9,620 KB
testcase_08 AC 19 ms
8,496 KB
testcase_09 AC 19 ms
8,424 KB
testcase_10 AC 90 ms
11,176 KB
testcase_11 AC 77 ms
10,012 KB
testcase_12 AC 95 ms
10,496 KB
testcase_13 AC 90 ms
10,392 KB
testcase_14 AC 19 ms
8,428 KB
testcase_15 AC 19 ms
8,604 KB
testcase_16 AC 19 ms
8,592 KB
testcase_17 AC 18 ms
8,452 KB
testcase_18 AC 19 ms
8,460 KB
testcase_19 AC 20 ms
8,452 KB
testcase_20 AC 19 ms
8,428 KB
testcase_21 AC 19 ms
8,492 KB
testcase_22 AC 19 ms
8,448 KB
testcase_23 AC 18 ms
8,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7

from collections import Counter

s = SI()
n = len(s)

if s!=s[::-1]:
    print(n)
    exit()

cnt = Counter(s)
if len(cnt) == 1:
    if n & 1: print(-1)
    else: print(0)
    exit()

if n == 3 and s == s[::-1]:
    print(-1)
    exit()

print(n-2)
0