結果
問題 |
No.1617 Palindrome Removal
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:40:52 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 564 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 82,108 KB |
実行使用メモリ | 77,808 KB |
最終ジャッジ日時 | 2025-06-12 20:41:04 |
合計ジャッジ時間 | 2,114 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 WA * 2 |
ソースコード
def main(): import sys s = sys.stdin.readline().strip() n = len(s) # Check if the string is a palindrome is_palindrome = s == s[::-1] if not is_palindrome: print(n) return # Check if all characters are the same all_same = True first = s[0] 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) if __name__ == "__main__": main()