結果

問題 No.1617 Palindrome Removal
ユーザー tassei903tassei903
提出日時 2021-07-22 22:16:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 88,268 KB
最終ジャッジ日時 2023-09-24 17:22:24
合計ジャッジ時間 3,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
87,336 KB
testcase_01 AC 104 ms
88,028 KB
testcase_02 AC 105 ms
87,396 KB
testcase_03 AC 104 ms
87,408 KB
testcase_04 AC 107 ms
88,104 KB
testcase_05 AC 99 ms
85,772 KB
testcase_06 AC 105 ms
88,268 KB
testcase_07 AC 95 ms
83,496 KB
testcase_08 AC 71 ms
71,340 KB
testcase_09 AC 73 ms
71,376 KB
testcase_10 AC 104 ms
87,088 KB
testcase_11 AC 102 ms
85,612 KB
testcase_12 AC 107 ms
87,952 KB
testcase_13 AC 105 ms
88,084 KB
testcase_14 AC 74 ms
71,180 KB
testcase_15 AC 71 ms
71,412 KB
testcase_16 AC 74 ms
71,328 KB
testcase_17 AC 73 ms
71,288 KB
testcase_18 AC 73 ms
71,492 KB
testcase_19 AC 74 ms
71,408 KB
testcase_20 AC 75 ms
71,216 KB
testcase_21 AC 73 ms
71,332 KB
testcase_22 AC 72 ms
71,172 KB
testcase_23 AC 72 ms
71,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
if len(s)==1:
    print(-1)
else:
    n = len(s)
    a = s[:(n+1)//2]
    b = s[::-1][:(n+1)//2]
    if sum([s[0]==s[i]for i in range(n)])==n and a==b:
        if n%2==0:
            print(0)
        else:
            print(-1)
    elif a==b:
        if n>=4:
            print(n-2)
        else:
            print(-1)
    else:
        print(n)

        
0