結果

問題 No.273 回文分解
ユーザー rlangevinrlangevin
提出日時 2023-01-14 13:13:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 365 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 76,572 KB
最終ジャッジ日時 2023-08-26 19:34:44
合計ジャッジ時間 4,154 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,292 KB
testcase_01 AC 68 ms
75,088 KB
testcase_02 AC 65 ms
71,120 KB
testcase_03 AC 66 ms
71,240 KB
testcase_04 AC 64 ms
71,020 KB
testcase_05 AC 70 ms
75,064 KB
testcase_06 AC 67 ms
75,188 KB
testcase_07 AC 67 ms
71,324 KB
testcase_08 AC 75 ms
75,148 KB
testcase_09 AC 70 ms
74,960 KB
testcase_10 AC 65 ms
71,168 KB
testcase_11 AC 67 ms
71,180 KB
testcase_12 AC 65 ms
71,172 KB
testcase_13 AC 63 ms
71,172 KB
testcase_14 AC 79 ms
76,276 KB
testcase_15 AC 64 ms
71,352 KB
testcase_16 AC 64 ms
71,000 KB
testcase_17 AC 67 ms
71,188 KB
testcase_18 AC 65 ms
71,052 KB
testcase_19 AC 68 ms
75,252 KB
testcase_20 AC 67 ms
71,352 KB
testcase_21 AC 65 ms
71,172 KB
testcase_22 AC 72 ms
76,348 KB
testcase_23 AC 75 ms
76,464 KB
testcase_24 AC 76 ms
76,288 KB
testcase_25 AC 76 ms
76,352 KB
testcase_26 AC 76 ms
76,260 KB
testcase_27 AC 75 ms
76,572 KB
testcase_28 AC 75 ms
76,324 KB
testcase_29 AC 71 ms
75,108 KB
testcase_30 AC 74 ms
76,420 KB
testcase_31 AC 65 ms
71,056 KB
testcase_32 AC 62 ms
71,360 KB
testcase_33 AC 63 ms
71,300 KB
testcase_34 AC 63 ms
71,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(L):
    N = len(L)
    temp = [None] * N
    for i in range(N):
        temp[i] = L[N - 1 - i]
    return L == temp

S = list(input())
M = len(S)
dp = [1] * M
for i in range(1, M):
    for j in range(i):
        if f(S[j+1:i+1]):
            dp[i] = max(dp[i], dp[j], i - j)
            if f(S[:j + 1]):
                dp[i] = max(dp[i], j + 1)
print(dp[-1])
0