結果

問題 No.225 文字列変更(medium)
ユーザー nebukuro09
提出日時 2016-09-23 16:00:17
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 376 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 6,784 KB
実行使用メモリ 169,664 KB
最終ジャッジ日時 2024-11-17 19:01:20
合計ジャッジ時間 38,353 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 11
権限があれば一括ダウンロードができます

ソースコード

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