結果
| 問題 |
No.1617 Palindrome Removal
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 16:21:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 493 bytes |
| コンパイル時間 | 182 ms |
| コンパイル使用メモリ | 82,148 KB |
| 実行使用メモリ | 76,468 KB |
| 最終ジャッジ日時 | 2025-04-16 16:22:30 |
| 合計ジャッジ時間 | 2,308 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 WA * 2 |
ソースコード
def is_palindrome(s):
n = len(s)
for i in range(n // 2):
if s[i] != s[n - 1 - i]:
return False
return True
def all_same(s):
if not s:
return True
c = s[0]
for char in s:
if char != c:
return False
return True
s = input().strip()
n = len(s)
if not is_palindrome(s):
print(n)
else:
if all_same(s):
if n % 2 == 0:
print(0)
else:
print(-1)
else:
print(n - 2)
lam6er