結果

問題 No.225 文字列変更(medium)
ユーザー nebukuro09nebukuro09
提出日時 2016-09-23 16:13:48
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 373 bytes
コンパイル時間 2,007 ms
コンパイル使用メモリ 77,632 KB
実行使用メモリ 80,012 KB
最終ジャッジ日時 2023-08-26 00:41:01
合計ジャッジ時間 4,946 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
79,800 KB
testcase_01 AC 102 ms
79,780 KB
testcase_02 AC 66 ms
76,420 KB
testcase_03 AC 65 ms
76,400 KB
testcase_04 AC 66 ms
76,592 KB
testcase_05 AC 68 ms
76,364 KB
testcase_06 AC 66 ms
76,364 KB
testcase_07 AC 66 ms
76,492 KB
testcase_08 AC 64 ms
76,656 KB
testcase_09 AC 66 ms
76,512 KB
testcase_10 AC 70 ms
76,488 KB
testcase_11 AC 68 ms
76,676 KB
testcase_12 AC 121 ms
79,668 KB
testcase_13 AC 110 ms
79,980 KB
testcase_14 AC 111 ms
79,896 KB
testcase_15 AC 113 ms
79,896 KB
testcase_16 AC 111 ms
79,916 KB
testcase_17 AC 117 ms
80,012 KB
testcase_18 AC 118 ms
80,000 KB
testcase_19 AC 113 ms
79,916 KB
testcase_20 AC 114 ms
80,000 KB
testcase_21 AC 113 ms
79,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dist = [[0 for i in xrange(M+1)] for j in xrange(N+1)]

for i in xrange(N+1):
    dist[i][0] = i
for j in xrange(M+1):
    dist[0][j] = j
for i in xrange(1, N+1):
    for j in xrange(1, M+1):
        dist[i][j] = min(dist[i-1][j]+1, dist[i][j-1]+1, dist[i-1][j-1]+(s1[i-1]!=s2[j-1]))
print dist[N][M]
0