結果

問題 No.1617 Palindrome Removal
ユーザー lam6er
提出日時 2025-04-15 23:55:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 533 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 81,984 KB
実行使用メモリ 76,508 KB
最終ジャッジ日時 2025-04-15 23:56:32
合計ジャッジ時間 2,394 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input().strip()
n = len(S)

# Check if the string is a palindrome
is_palindrome = True
for i in range(n // 2):
    if S[i] != S[n - 1 - i]:
        is_palindrome = False
        break

if not is_palindrome:
    print(n)
else:
    # Check if all characters are the same
    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)
    else:
        print(n - 2)
0