結果

問題 No.273 回文分解
ユーザー convexineqconvexineq
提出日時 2020-12-19 23:42:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 379 bytes
コンパイル時間 1,347 ms
コンパイル使用メモリ 81,196 KB
実行使用メモリ 66,304 KB
最終ジャッジ日時 2023-10-21 09:41:47
合計ジャッジ時間 3,403 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,396 KB
testcase_01 AC 44 ms
59,492 KB
testcase_02 AC 34 ms
53,416 KB
testcase_03 AC 34 ms
53,416 KB
testcase_04 AC 32 ms
53,416 KB
testcase_05 AC 37 ms
59,492 KB
testcase_06 AC 37 ms
59,492 KB
testcase_07 AC 34 ms
53,416 KB
testcase_08 AC 47 ms
62,136 KB
testcase_09 AC 42 ms
59,496 KB
testcase_10 AC 33 ms
53,416 KB
testcase_11 AC 32 ms
53,416 KB
testcase_12 AC 34 ms
53,416 KB
testcase_13 AC 34 ms
53,416 KB
testcase_14 AC 45 ms
64,244 KB
testcase_15 AC 32 ms
53,416 KB
testcase_16 AC 33 ms
53,416 KB
testcase_17 AC 34 ms
53,416 KB
testcase_18 AC 32 ms
53,416 KB
testcase_19 AC 37 ms
59,496 KB
testcase_20 AC 31 ms
53,416 KB
testcase_21 AC 32 ms
53,416 KB
testcase_22 AC 48 ms
66,292 KB
testcase_23 AC 50 ms
66,304 KB
testcase_24 AC 45 ms
64,232 KB
testcase_25 AC 47 ms
66,292 KB
testcase_26 AC 47 ms
66,296 KB
testcase_27 AC 49 ms
64,220 KB
testcase_28 AC 48 ms
64,200 KB
testcase_29 AC 46 ms
64,208 KB
testcase_30 AC 44 ms
64,204 KB
testcase_31 AC 33 ms
53,416 KB
testcase_32 AC 34 ms
53,416 KB
testcase_33 AC 35 ms
53,416 KB
testcase_34 AC 35 ms
53,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
n = len(s)
dp = [[-1]*(n+1) for _ in range(n+1)]
for l in range(n,-1,-1):
    for r in range(l+1,n+1):
        if (l != 0 or r != n) and s[l:r] == s[l:r][::-1]:
            dp[l][r] = r-l
        else:
            for x in range(l+1,r):
                if dp[l][x] >= 0 and dp[x][r] >= 0:
                    dp[l][r] = max(dp[l][r],dp[l][x],dp[x][r])
print(dp[l][r])
0