結果
| 問題 | No.1617 Palindrome Removal | 
| コンテスト | |
| ユーザー |  lam6er | 
| 提出日時 | 2025-03-20 18:48:28 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 580 bytes | 
| コンパイル時間 | 209 ms | 
| コンパイル使用メモリ | 82,888 KB | 
| 実行使用メモリ | 78,396 KB | 
| 最終ジャッジ日時 | 2025-03-20 18:49:52 | 
| 合計ジャッジ時間 | 2,239 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 18 WA * 2 | 
ソースコード
def is_palindrome(s):
    return s == s[::-1]
def main():
    s = input().strip()
    n = len(s)
    if not is_palindrome(s):
        print(n)
        return
    all_same = True
    first_char = s[0]
    for c in s:
        if c != first_char:
            all_same = False
            break
    if all_same:
        if n % 2 == 0:
            print(0)
        else:
            print(-1)
        return
    # Else, not all characters are the same and it's a palindrome
    candidate = n - 2
    print(candidate if candidate >= 0 else -1)
if __name__ == "__main__":
    main()
            
            
            
        