結果

問題 No.225 文字列変更(medium)
ユーザー TawaraTawara
提出日時 2015-08-04 20:13:30
言語 Python2
(2.7.18)
結果
AC  
実行時間 769 ms / 5,000 ms
コード長 336 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 6,708 KB
実行使用メモリ 34,052 KB
最終ジャッジ日時 2023-08-25 23:04:14
合計ジャッジ時間 10,005 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 302 ms
15,944 KB
testcase_01 AC 509 ms
24,588 KB
testcase_02 AC 11 ms
6,076 KB
testcase_03 AC 11 ms
5,840 KB
testcase_04 AC 11 ms
5,992 KB
testcase_05 AC 12 ms
5,868 KB
testcase_06 AC 11 ms
5,840 KB
testcase_07 AC 11 ms
6,100 KB
testcase_08 AC 11 ms
6,052 KB
testcase_09 AC 11 ms
6,028 KB
testcase_10 AC 11 ms
5,872 KB
testcase_11 AC 12 ms
5,840 KB
testcase_12 AC 716 ms
30,840 KB
testcase_13 AC 769 ms
34,052 KB
testcase_14 AC 754 ms
33,076 KB
testcase_15 AC 706 ms
26,068 KB
testcase_16 AC 717 ms
31,976 KB
testcase_17 AC 715 ms
26,252 KB
testcase_18 AC 697 ms
28,940 KB
testcase_19 AC 713 ms
32,156 KB
testcase_20 AC 681 ms
29,220 KB
testcase_21 AC 712 ms
31,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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