結果

問題 No.1617 Palindrome Removal
ユーザー ntuda
提出日時 2021-09-05 22:27:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 486 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 77,580 KB
最終ジャッジ日時 2024-12-22 18:59:17
合計ジャッジ時間 4,068 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys

S = input()
D = collections.Counter(S)
ND = len(D)
N = len(S)

if N == 1:
    print(-1)
elif N == 2:
    if ND == 1:
        print(0)
    else:
        print(N)
elif N == 3:
    if ND == 1:
        print(-1)
    elif S[0] == S[2]:
        print(1)
    else:
        print(3)
else:
    if ND == 1:
        if N % 2 == 0:
            print(0)
        else:
            print(-1)
    elif S[:N//2] == S[:-(-N//2)-1:-1]:
        print(N-2)
    else:
        print(N)
0