結果

問題 No.1617 Palindrome Removal
ユーザー wolgnik
提出日時 2021-07-22 21:31:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 274 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 213,376 KB
最終ジャッジ日時 2024-07-17 16:37:59
合計ジャッジ時間 3,716 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
S = list(map(lambda x: ord(x) - ord("a"), list(input())[: -1]))

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

if S != S[: : -1]:
  print(len(S))
  exit(0)

if len(S) != 3: print(len(S) - 2)
else: print(-1)
0