結果
| 問題 |
No.225 文字列変更(medium)
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-06-13 20:47:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 5,000 ms |
| コード長 | 483 bytes |
| コンパイル時間 | 716 ms |
| コンパイル使用メモリ | 57,692 KB |
| 実行使用メモリ | 7,296 KB |
| 最終ジャッジ日時 | 2024-12-24 10:12:49 |
| 合計ジャッジ時間 | 1,390 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
#include <iostream>
#include <algorithm>
int N, M;
std::string S, T;
int dp[1001][1001];
int main(){
std::cin >> N >> M;
std::cin >> S >> T;
for(int i=1;i<=N;i++){
dp[i][0] = i;
}
for(int i=1;i<=M;i++){
dp[0][i] = i;
}
for(int i=1;i<=N;i++){
for(int j=1;j<=M;j++){
dp[i][j] = std::min({dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + (S[i-1] != T[j-1])});
}
}
std::cout << dp[N][M] << std::endl;
}
tottoripaper