結果

問題 No.225 文字列変更(medium)
ユーザー koyumeishikoyumeishi
提出日時 2015-06-12 22:29:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 596 bytes
コンパイル時間 692 ms
コンパイル使用メモリ 77,776 KB
実行使用メモリ 7,248 KB
最終ジャッジ日時 2023-09-20 21:06:25
合計ジャッジ時間 1,537 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 7 ms
6,892 KB
testcase_13 AC 7 ms
7,248 KB
testcase_14 AC 7 ms
7,032 KB
testcase_15 AC 7 ms
6,988 KB
testcase_16 AC 7 ms
7,120 KB
testcase_17 AC 7 ms
6,876 KB
testcase_18 AC 7 ms
6,748 KB
testcase_19 AC 7 ms
6,960 KB
testcase_20 AC 6 ms
6,780 KB
testcase_21 AC 7 ms
6,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	string s,t;
	cin >> s >> t;
	vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
	for(int i=0; i<n; i++){
		dp[i][0] = i;
	}
	for(int i=0; i<m; i++){
		dp[0][i] = i;
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			dp[i][j] = min({dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + (s[i-1]!=t[j-1]?1:0)});
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}
0