結果

問題 No.225 文字列変更(medium)
ユーザー 夜
提出日時 2020-12-10 22:26:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 680 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 93,548 KB
実行使用メモリ 7,608 KB
最終ジャッジ日時 2023-10-20 00:56:27
合計ジャッジ時間 1,674 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,380 KB
testcase_01 AC 5 ms
7,608 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 6 ms
7,248 KB
testcase_13 AC 6 ms
7,508 KB
testcase_14 AC 6 ms
7,480 KB
testcase_15 AC 6 ms
7,308 KB
testcase_16 AC 6 ms
7,512 KB
testcase_17 AC 6 ms
7,268 KB
testcase_18 AC 6 ms
7,216 KB
testcase_19 AC 6 ms
7,400 KB
testcase_20 AC 5 ms
7,236 KB
testcase_21 AC 6 ms
7,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int dp[1010][1010];
int main() {
	int n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	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]) });
		}
	}
	cout << dp[n][m] << endl;
}
0