結果

問題 No.225 文字列変更(medium)
ユーザー nebukuro09nebukuro09
提出日時 2016-09-23 16:00:17
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 376 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 6,784 KB
実行使用メモリ 169,792 KB
最終ジャッジ日時 2024-04-28 22:19:39
合計ジャッジ時間 48,973 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 11 ms
6,144 KB
testcase_03 AC 11 ms
6,144 KB
testcase_04 AC 12 ms
6,144 KB
testcase_05 AC 12 ms
6,016 KB
testcase_06 WA -
testcase_07 AC 12 ms
6,144 KB
testcase_08 AC 11 ms
6,272 KB
testcase_09 AC 12 ms
6,272 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 4,885 ms
169,792 KB
testcase_14 WA -
testcase_15 AC 3,951 ms
158,396 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 4,078 ms
161,416 KB
testcase_21 AC 4,039 ms
162,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10000)
N, M = map(int, raw_input().split())
s1, s2 = raw_input(), raw_input()

mem = {}
def rec(n, m):
    if (n, m) in mem:
        return mem[(n, m)]
    if n == 0:
        return m
    if m == 0:
        return n
    mem[(n, m)] = min(rec(n-1, m)+1, rec(n, m-1)+1, rec(n-1, m-1)+(s1[n]!=s2[m]))
    return mem[(n, m)]

print rec(N-1, M-1)
0