結果

問題 No.588 空白と回文
ユーザー 👑 KazunKazun
提出日時 2020-11-27 03:54:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 890 ms / 2,000 ms
コード長 596 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 86,696 KB
実行使用メモリ 82,256 KB
最終ジャッジ日時 2023-10-01 03:53:25
合計ジャッジ時間 8,148 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
79,940 KB
testcase_01 AC 143 ms
79,916 KB
testcase_02 AC 140 ms
80,012 KB
testcase_03 AC 853 ms
82,256 KB
testcase_04 AC 140 ms
79,980 KB
testcase_05 AC 140 ms
80,004 KB
testcase_06 AC 144 ms
80,732 KB
testcase_07 AC 143 ms
80,048 KB
testcase_08 AC 147 ms
79,836 KB
testcase_09 AC 144 ms
79,808 KB
testcase_10 AC 142 ms
79,988 KB
testcase_11 AC 890 ms
81,888 KB
testcase_12 AC 184 ms
82,072 KB
testcase_13 AC 143 ms
79,988 KB
testcase_14 AC 140 ms
79,936 KB
testcase_15 AC 145 ms
79,984 KB
testcase_16 AC 140 ms
79,956 KB
testcase_17 AC 480 ms
82,148 KB
testcase_18 AC 144 ms
79,864 KB
testcase_19 AC 140 ms
79,972 KB
testcase_20 AC 239 ms
81,884 KB
testcase_21 AC 596 ms
81,976 KB
testcase_22 AC 263 ms
82,100 KB
testcase_23 AC 429 ms
82,040 KB
testcase_24 AC 149 ms
79,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from string import ascii_lowercase

X=ascii_lowercase+"0123456789"
D={x:[] for x in X}

S=input()
N=len(S)

for i in range(N):
    D[S[i]].append(i)

#長さが奇数
K=0
for i in range(N):
    e=1
    A=1
    while 0<=i-e and i+e<N:
        if S[i-e]==S[i+e]:A+=2
        e+=1
    K=max(K,A)

#長さが偶数
for x in D:
    E=D[x]
    L=len(E)

    for i in range(L):
        p=E[i]
        for j in range(i+1,L):
            e=1
            A=2
            q=E[j]
            while 0<=p-e and q+e<N:
                if S[p-e]==S[q+e]:A+=2
                e+=1
            K=max(K,A)

print(K)
0