結果

問題 No.225 文字列変更(medium)
ユーザー pluto77pluto77
提出日時 2017-09-08 09:36:20
言語 Python2
(2.7.18)
結果
AC  
実行時間 769 ms / 5,000 ms
コード長 333 bytes
コンパイル時間 814 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 34,176 KB
最終ジャッジ日時 2024-04-24 19:53:26
合計ジャッジ時間 10,150 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 294 ms
16,256 KB
testcase_01 AC 498 ms
25,088 KB
testcase_02 AC 9 ms
6,272 KB
testcase_03 AC 10 ms
6,144 KB
testcase_04 AC 9 ms
6,144 KB
testcase_05 AC 10 ms
6,016 KB
testcase_06 AC 10 ms
6,144 KB
testcase_07 AC 10 ms
6,144 KB
testcase_08 AC 10 ms
6,144 KB
testcase_09 AC 10 ms
6,144 KB
testcase_10 AC 10 ms
6,272 KB
testcase_11 AC 9 ms
6,144 KB
testcase_12 AC 702 ms
31,104 KB
testcase_13 AC 769 ms
34,176 KB
testcase_14 AC 734 ms
33,024 KB
testcase_15 AC 691 ms
26,240 KB
testcase_16 AC 718 ms
32,256 KB
testcase_17 AC 708 ms
26,368 KB
testcase_18 AC 689 ms
29,056 KB
testcase_19 AC 710 ms
32,384 KB
testcase_20 AC 665 ms
29,568 KB
testcase_21 AC 714 ms
32,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki_225

n,m=map(int,raw_input().split())
s=raw_input()
t=raw_input()
dp=[[0 for i in xrange(n+1)] for j in range(m+1)]
for i in xrange(n+1):
 dp[0][i]=i
for i in xrange(1,m+1):
 dp[i][0]=i

for i in xrange(1,m+1):
 for j in xrange(1,n+1):
  dp[i][j] = min(dp[i][j-1]+1, dp[i-1][j]+1, dp[i-1][j-1]+(t[i-1]!=s[j-1]))
print dp[m][n]
0