結果

問題 No.1617 Palindrome Removal
ユーザー O2MTO2MT
提出日時 2021-07-23 17:30:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 127,616 KB
最終ジャッジ日時 2023-09-25 15:53:30
合計ジャッジ時間 5,424 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
123,524 KB
testcase_01 AC 189 ms
126,312 KB
testcase_02 AC 190 ms
125,204 KB
testcase_03 AC 191 ms
124,704 KB
testcase_04 AC 196 ms
127,616 KB
testcase_05 AC 176 ms
117,232 KB
testcase_06 AC 199 ms
127,460 KB
testcase_07 AC 165 ms
106,448 KB
testcase_08 AC 91 ms
71,716 KB
testcase_09 AC 91 ms
71,864 KB
testcase_10 AC 196 ms
124,044 KB
testcase_11 AC 177 ms
117,752 KB
testcase_12 AC 198 ms
127,356 KB
testcase_13 AC 198 ms
127,488 KB
testcase_14 AC 91 ms
71,556 KB
testcase_15 AC 90 ms
71,616 KB
testcase_16 AC 91 ms
71,552 KB
testcase_17 AC 91 ms
71,660 KB
testcase_18 AC 90 ms
71,748 KB
testcase_19 AC 91 ms
71,588 KB
testcase_20 AC 92 ms
71,416 KB
testcase_21 AC 93 ms
71,720 KB
testcase_22 AC 90 ms
71,636 KB
testcase_23 AC 89 ms
71,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

S = str(input())
N = len(S)
if N == 1:
  print(-1)
  exit()
ls = list(S)
cs = Counter(ls)
if len(cs) == 1:
  if N%2 == 0:
    print(0)
  else:
    print(-1)
else:
  l = S[:N//2]
  if N%2 == 0:
    r = S[-1:N//2-1:-1]
  else:
    r = S[-1:N//2:-1]
  if l != r:
    print(N)
  else:
    if N == 3:
      print(-1)
    else:
      print(N-2)
0