結果
| 問題 |
No.1617 Palindrome Removal
|
| コンテスト | |
| ユーザー |
m1k__
|
| 提出日時 | 2021-07-22 22:03:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 66 ms / 2,000 ms |
| コード長 | 430 bytes |
| コンパイル時間 | 306 ms |
| コンパイル使用メモリ | 82,256 KB |
| 実行使用メモリ | 77,184 KB |
| 最終ジャッジ日時 | 2024-07-17 17:54:33 |
| 合計ジャッジ時間 | 2,449 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
S = input()
cnt = [0]*26
f = 1
lenS = len(S)
for i in range(lenS//2):
si, sj = S[i], S[lenS-1-i]
f *= si==sj
cnt[ord(si)-97] += 1
cnt[ord(sj)-97] += 1
if lenS%2:
s = S[lenS//2]
cnt[ord(s)-97] += 1
if f:
lst = [c for c in cnt if c>0]
if len(lst)==1:
print(-1 if lenS%2 else 0)
else:
if lenS==3:
print(-1)
else:
print(lenS-2)
else:
print(lenS)
m1k__