結果
| 問題 |
No.225 文字列変更(medium)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-26 03:27:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,114 bytes |
| コンパイル時間 | 695 ms |
| コンパイル使用メモリ | 84,148 KB |
| 実行使用メモリ | 10,944 KB |
| 最終ジャッジ日時 | 2024-06-27 21:37:59 |
| 合計ジャッジ時間 | 1,543 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 5 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
string s, t;
cin >> s >> t;
ll dp[n + 1][m + 1];
rep(i, 0, n + 1) rep(j, 0 , m + 1) dp[i][j] = INF;
dp[0][0] = 0;
rep(i, 0, n) {
rep(j, 0, m) {
if(s[i] == t[j]) dp[i + 1][j + 1] = min(dp[i][j], min(dp[i + 1][j] + 1, dp[i][j + 1] + 1));
else dp[i + 1][j + 1] = min(dp[i][j] + 1, min(dp[i + 1][j] + 1, dp[i][j + 1] + 1));
}
}
cout << dp[n][m] << endl;
}