結果

問題 No.225 文字列変更(medium)
ユーザー nebukuro09nebukuro09
提出日時 2016-09-23 15:59:30
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 335 bytes
コンパイル時間 52 ms
コンパイル使用メモリ 6,784 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-04-28 22:17:23
合計ジャッジ時間 1,394 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 12 ms
6,144 KB
testcase_03 AC 12 ms
6,144 KB
testcase_04 AC 11 ms
6,272 KB
testcase_05 AC 11 ms
6,272 KB
testcase_06 WA -
testcase_07 AC 11 ms
6,272 KB
testcase_08 AC 11 ms
6,016 KB
testcase_09 AC 12 ms
6,272 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 #

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