結果
問題 |
No.1617 Palindrome Removal
|
ユーザー |
![]() |
提出日時 | 2025-04-16 00:03:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 493 bytes |
コンパイル時間 | 261 ms |
コンパイル使用メモリ | 81,460 KB |
実行使用メモリ | 76,180 KB |
最終ジャッジ日時 | 2025-04-16 00:05:06 |
合計ジャッジ時間 | 2,366 ms |
ジャッジサーバーID (参考情報) |
judge4 / 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)