結果
| 問題 |
No.1617 Palindrome Removal
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2021-09-05 22:29:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 125 ms / 2,000 ms |
| コード長 | 451 bytes |
| コンパイル時間 | 437 ms |
| コンパイル使用メモリ | 82,340 KB |
| 実行使用メモリ | 77,788 KB |
| 最終ジャッジ日時 | 2024-12-22 19:00:08 |
| 合計ジャッジ時間 | 3,491 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
import collections,sys
S = input()
D = collections.Counter(S)
ND = len(D)
N = len(S)
if N == 1:
print(-1)
elif N == 2:
if ND == 1:
print(0)
else:
print(N)
elif N == 3:
if S[0] == S[2]:
print(-1)
else:
print(3)
else:
if ND == 1:
if N % 2 == 0:
print(0)
else:
print(-1)
elif S[:N//2] == S[:-(-N//2)-1:-1]:
print(N-2)
else:
print(N)
ntuda