結果

問題 No.1617 Palindrome Removal
ユーザー O2MT
提出日時 2021-07-23 17:30:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 124,952 KB
最終ジャッジ日時 2024-07-18 12:32:56
合計ジャッジ時間 3,660 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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