結果

問題 No.225 文字列変更(medium)
ユーザー nebukuro09
提出日時 2016-09-23 16:02:27
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 380 bytes
コンパイル時間 2,284 ms
コンパイル使用メモリ 76,800 KB
実行使用メモリ 274,472 KB
最終ジャッジ日時 2024-11-17 19:01:58
合計ジャッジ時間 19,374 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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+1
    if m == 0:
        return n+1
    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