結果

問題 No.225 文字列変更(medium)
ユーザー kuc_jacksonkuc_jackson
提出日時 2021-05-02 13:40:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 744 bytes
コンパイル時間 2,084 ms
コンパイル使用メモリ 204,376 KB
実行使用メモリ 7,172 KB
最終ジャッジ日時 2023-09-28 03:45:38
合計ジャッジ時間 3,509 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,820 KB
testcase_01 AC 5 ms
5,924 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 7 ms
6,840 KB
testcase_13 WA -
testcase_14 AC 7 ms
7,136 KB
testcase_15 AC 6 ms
6,900 KB
testcase_16 AC 7 ms
6,904 KB
testcase_17 AC 6 ms
6,988 KB
testcase_18 AC 7 ms
6,740 KB
testcase_19 AC 7 ms
6,932 KB
testcase_20 AC 7 ms
6,684 KB
testcase_21 AC 7 ms
7,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
template<typename T> inline bool chmax(T &a, const T &b){if(a < b){a = b; return true;}return false;}
using namespace std;
using ll = long long;

ll INF = 1e8;

int main(){
    int N, M; cin >> N >> M;
    string S, T; cin >> S >> T;
    vector<vector<int>> dp(N + 1, vector<int>(M + 1, INF));
    dp[0][0] = 0;
    for(int i = 0; i < N; i++)dp[i + 1][0] = dp[i + 1][0] + 1;
    for(int i = 0; i < M; i++)dp[0][i + 1] = dp[0][i] + 1;
    for(int i = 0; i < N; i++)for(int j = 0; j < M; j++){
        if(S[i] == T[j])dp[i + 1][j + 1] = min(dp[i][j], min(dp[i][j + 1] + 1, dp[i + 1][j] + 1));
        else dp[i + 1][j + 1] = min(dp[i][j] + 1, min(dp[i][j + 1] + 1, dp[i + 1][j] + 1));
    }
    cout << dp[N][M] << endl;
}
0