結果

問題 No.1617 Palindrome Removal
ユーザー 👑 SPD_9X2
提出日時 2021-07-22 21:28:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 126,744 KB
最終ジャッジ日時 2024-07-17 16:23:40
合計ジャッジ時間 3,112 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

S = list(input())
N = len(S)

s = set(S)

if len(s) == 1:
    if len(S) % 2 == 1:
        print (-1)
    else:
        print (0)
else:

    flag = True
    for i in range(N):

        if S[i] != S[len(S)-1-i]:
            flag = False

    if not flag:
        print (len(S))
    elif len(S) % 2 == 0:
        print (len(S)-2)
    else:
        om = set(S[:N//2] + S[N//2+1:])
        if len(om) == 1 and N == 3:
            print (-1)
        else:
            print (len(S)-2)
0