結果

問題 No.225 文字列変更(medium)
ユーザー CsTarepandaCsTarepanda
提出日時 2019-06-30 19:39:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 418 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 102,692 KB
最終ジャッジ日時 2023-09-20 18:30:03
合計ジャッジ時間 4,870 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 AC 73 ms
71,292 KB
testcase_03 AC 74 ms
71,176 KB
testcase_04 AC 73 ms
71,416 KB
testcase_05 AC 74 ms
71,328 KB
testcase_06 WA -
testcase_07 AC 72 ms
71,332 KB
testcase_08 AC 71 ms
71,572 KB
testcase_09 AC 73 ms
71,664 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

slen, tlen = map(int, input().split())
s = input()
t = input()

dp = [[None] * tlen for _ in range(slen)]
def dfs(a=slen - 1, b=tlen - 1):
    if a == 0:
        return b
    if b == 0:
        return a

    if dp[a][b] is not None:
        return dp[a][b]
    r = min(
        dfs(a - 1, b) + 1,
        dfs(a, b - 1) + 1,
        dfs(a - 1, b - 1) + (s[a] != t[b]),
    )
    dp[a][b] = r
    return r

print(dfs())
0