結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 7 ms
7,508 KB
testcase_14 WA -
testcase_15 AC 6 ms
7,308 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 6 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] != t[j]) });
		}
	}
	cout << dp[n][m] << endl;
}
0