結果

問題 No.1617 Palindrome Removal
ユーザー gew1fw
提出日時 2025-06-12 15:49:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 452 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 82,796 KB
実行使用メモリ 79,016 KB
最終ジャッジ日時 2025-06-12 15:50:00
合計ジャッジ時間 2,746 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input().strip()

# Function to check if the string is a palindrome
def is_palindrome(s):
    return s == s[::-1]

if not is_palindrome(s):
    print(len(s))
else:
    # Check if all characters are the same
    all_same = all(c == s[0] for c in s)
    if all_same:
        if len(s) % 2 == 0:
            print(0)
        else:
            print(-1)
    else:
        if len(s) == 1:
            print(-1)
        else:
            print(len(s) - 2)
0