結果
問題 |
No.225 文字列変更(medium)
|
ユーザー |
![]() |
提出日時 | 2017-04-03 12:05:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 596 bytes |
コンパイル時間 | 621 ms |
コンパイル使用メモリ | 75,960 KB |
実行使用メモリ | 7,296 KB |
最終ジャッジ日時 | 2024-07-08 03:15:33 |
合計ジャッジ時間 | 1,223 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <stdio.h> #include <string.h> using namespace std; int main() { int n, m; string s, t; cin >> n >> m >> s >> t; vector<vector<int>> dp(n + 1, vector<int>(m + 1)); for (int j = 0; j <= m; j++) { dp[0][j] = j; } for (int i = 1; i <= n; i++) { dp[i][0] = i; for (int j = 1; j <= m; j++) { dp[i][j] = min(min(dp[i][j - 1], dp[i - 1][j]) + 1, dp[i - 1][j - 1] + (s[i - 1] != t[j - 1])); } } cout << dp[n][m] << endl; return 0; }