結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-02-03 23:38:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 567 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 273,640 KB
最終ジャッジ日時 2023-09-15 19:56:29
合計ジャッジ時間 11,460 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,088 KB
testcase_01 AC 74 ms
71,408 KB
testcase_02 AC 72 ms
71,228 KB
testcase_03 AC 227 ms
183,296 KB
testcase_04 AC 113 ms
92,136 KB
testcase_05 AC 107 ms
91,452 KB
testcase_06 AC 328 ms
273,208 KB
testcase_07 AC 299 ms
252,052 KB
testcase_08 AC 278 ms
229,772 KB
testcase_09 AC 288 ms
243,996 KB
testcase_10 AC 321 ms
273,516 KB
testcase_11 AC 274 ms
229,640 KB
testcase_12 AC 318 ms
271,356 KB
testcase_13 AC 317 ms
273,092 KB
testcase_14 AC 320 ms
273,252 KB
testcase_15 AC 298 ms
252,536 KB
testcase_16 AC 165 ms
137,488 KB
testcase_17 AC 207 ms
175,012 KB
testcase_18 AC 321 ms
273,516 KB
testcase_19 AC 328 ms
273,512 KB
testcase_20 AC 319 ms
273,572 KB
testcase_21 AC 324 ms
273,360 KB
testcase_22 AC 322 ms
273,032 KB
testcase_23 AC 321 ms
273,224 KB
testcase_24 AC 328 ms
273,496 KB
testcase_25 AC 329 ms
273,572 KB
testcase_26 AC 325 ms
273,444 KB
testcase_27 AC 241 ms
203,644 KB
testcase_28 AC 325 ms
273,476 KB
testcase_29 AC 324 ms
273,640 KB
testcase_30 AC 70 ms
71,376 KB
testcase_31 AC 72 ms
71,148 KB
testcase_32 AC 567 ms
224,068 KB
testcase_33 AC 321 ms
273,124 KB
testcase_34 AC 71 ms
71,192 KB
testcase_35 AC 561 ms
223,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
n = len(S)
pal = [[0]*(n+1) for i in range(n+1)]


for i in range(n):
    l = i
    r = i
    while l >= 0 and r < n and S[l] == S[r]:
        pal[l][r+1] = 1
        l -= 1
        r += 1

    l = i
    r = i+1
    
    while l >= 0 and r < n and S[l] == S[r]:
        pal[l][r+1] = 1
        l -= 1
        r += 1

dp = [-1]*(n+1)
dp[0] = n+1
for i in range(n):
    if dp[i] == -1:
        continue
    for j in range(i+1,n+1):
        if pal[i][j]:
            dp[j] = max(dp[j],min(dp[i],j-i))
print(dp[-1])
0