結果
| 問題 |
No.1617 Palindrome Removal
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 00:03:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 538 bytes |
| コンパイル時間 | 441 ms |
| コンパイル使用メモリ | 82,248 KB |
| 実行使用メモリ | 78,508 KB |
| 最終ジャッジ日時 | 2025-04-16 00:05:25 |
| 合計ジャッジ時間 | 2,389 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 WA * 2 |
ソースコード
def is_palindrome(s):
return s == s[::-1]
def solve():
import sys
s = sys.stdin.readline().strip()
n = len(s)
if n == 0:
print(-1)
return
if not is_palindrome(s):
print(n)
return
# Check if all characters are the same
first = s[0]
all_same = True
for c in s:
if c != first:
all_same = False
break
if all_same:
if n % 2 == 0:
print(0)
else:
print(-1)
else:
print(n - 2)
solve()
lam6er