結果
| 問題 | No.225 文字列変更(medium) |
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2016-01-11 22:49:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 680 bytes |
| コンパイル時間 | 668 ms |
| コンパイル使用メモリ | 62,488 KB |
| 実行使用メモリ | 7,424 KB |
| 最終ジャッジ日時 | 2024-09-19 18:48:18 |
| 合計ジャッジ時間 | 1,739 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 17 |
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <cstring>
using namespace std;
int main(int argc, char *argv[]) {
int N, M;
string S, T;
cin >> N >> M >> S >> T;
int dp[1001][1001] = {}, slen = S.length(), tlen = T.length();
for (int j = 1; j <= tlen; ++j) {
dp[0][j] = j;
}
for (int i = 1; i <= slen; ++i) {
for (int j = 1; j <= tlen; ++j) {
int cost = min(dp[i - 1][j] + 1, dp[i - 1][j - 1] + 1);
if (j > 1) {
cost = min(cost, dp[i][j - 1] + 1);
}
if (S[i - 1] == T[j - 1]) {
cost = min(cost, dp[i - 1][j - 1]);
}
dp[i][j] = cost;
}
}
int ans = dp[slen][tlen];
cout << ans << endl;
return 0;
}
hotpepsi