結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
79,988 KB
testcase_01 AC 151 ms
80,076 KB
testcase_02 AC 151 ms
80,116 KB
testcase_03 AC 899 ms
82,068 KB
testcase_04 AC 151 ms
80,108 KB
testcase_05 AC 150 ms
80,072 KB
testcase_06 AC 156 ms
81,148 KB
testcase_07 AC 154 ms
80,076 KB
testcase_08 AC 155 ms
80,100 KB
testcase_09 AC 153 ms
80,080 KB
testcase_10 AC 155 ms
80,008 KB
testcase_11 AC 942 ms
82,300 KB
testcase_12 AC 198 ms
82,132 KB
testcase_13 AC 157 ms
80,296 KB
testcase_14 AC 160 ms
80,076 KB
testcase_15 AC 162 ms
80,080 KB
testcase_16 AC 159 ms
80,100 KB
testcase_17 AC 518 ms
82,116 KB
testcase_18 AC 152 ms
79,988 KB
testcase_19 AC 152 ms
80,056 KB
testcase_20 AC 260 ms
82,204 KB
testcase_21 AC 648 ms
82,036 KB
testcase_22 AC 279 ms
82,276 KB
testcase_23 AC 457 ms
82,160 KB
testcase_24 AC 149 ms
79,880 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
    if K<A: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
            if K<A:K=A

print(K)
0