結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー minatominato
提出日時 2023-03-09 06:59:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 904 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 271,984 KB
最終ジャッジ日時 2023-10-18 06:12:24
合計ジャッジ時間 22,080 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,552 KB
testcase_01 AC 38 ms
53,552 KB
testcase_02 AC 38 ms
53,552 KB
testcase_03 AC 400 ms
183,720 KB
testcase_04 AC 129 ms
91,668 KB
testcase_05 AC 109 ms
89,876 KB
testcase_06 AC 805 ms
271,800 KB
testcase_07 AC 614 ms
250,600 KB
testcase_08 AC 527 ms
229,640 KB
testcase_09 AC 559 ms
229,656 KB
testcase_10 AC 806 ms
271,776 KB
testcase_11 AC 523 ms
229,668 KB
testcase_12 AC 705 ms
269,912 KB
testcase_13 AC 700 ms
271,760 KB
testcase_14 AC 806 ms
271,748 KB
testcase_15 AC 607 ms
252,788 KB
testcase_16 AC 274 ms
137,720 KB
testcase_17 AC 340 ms
160,656 KB
testcase_18 AC 794 ms
271,756 KB
testcase_19 AC 802 ms
271,812 KB
testcase_20 AC 792 ms
271,760 KB
testcase_21 AC 696 ms
271,752 KB
testcase_22 AC 701 ms
271,656 KB
testcase_23 AC 700 ms
271,660 KB
testcase_24 AC 904 ms
271,984 KB
testcase_25 AC 896 ms
271,860 KB
testcase_26 AC 798 ms
271,856 KB
testcase_27 AC 477 ms
202,188 KB
testcase_28 AC 802 ms
271,840 KB
testcase_29 AC 704 ms
271,736 KB
testcase_30 AC 36 ms
53,552 KB
testcase_31 AC 38 ms
53,552 KB
testcase_32 AC 904 ms
222,648 KB
testcase_33 AC 802 ms
271,764 KB
testcase_34 AC 37 ms
53,552 KB
testcase_35 AC 896 ms
222,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = list(input())
N = len(S)

ok = [[False] * N for _ in range(N)]
for i in range(N):
    l = r = i
    while l >= 0 and r < N and S[l] == S[r]:
        ok[l][r] = True
        l -= 1
        r += 1

    l = i
    r = i + 1
    while l >= 0 and r < N and S[l] == S[r]:
        ok[l][r] = True
        l -= 1
        r += 1

INF = 10**9
dp = [0] * (N + 1)
dp[0] = INF

for i in range(1, N + 1):
    for j in range(i):
        if ok[j][i - 1]:
            dp[i] = max(dp[i], min(dp[j], i - j))

print(dp[N])
0