結果

問題 No.225 文字列変更(medium)
ユーザー nebukuro09nebukuro09
提出日時 2016-09-23 16:02:27
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 380 bytes
コンパイル時間 969 ms
コンパイル使用メモリ 77,056 KB
実行使用メモリ 274,608 KB
最終ジャッジ日時 2024-04-28 22:20:15
合計ジャッジ時間 18,588 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 599 ms
183,340 KB
testcase_01 AC 922 ms
256,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 90 ms
75,392 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 90 ms
75,648 KB
testcase_11 AC 90 ms
75,648 KB
testcase_12 AC 1,363 ms
273,892 KB
testcase_13 WA -
testcase_14 AC 1,522 ms
273,564 KB
testcase_15 WA -
testcase_16 AC 1,451 ms
273,360 KB
testcase_17 AC 1,447 ms
274,608 KB
testcase_18 AC 1,406 ms
274,584 KB
testcase_19 AC 1,404 ms
274,296 KB
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

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