結果

問題 No.225 文字列変更(medium)
ユーザー kuc_jacksonkuc_jackson
提出日時 2021-05-02 13:24:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 681 bytes
コンパイル時間 5,472 ms
コンパイル使用メモリ 202,040 KB
実行使用メモリ 7,188 KB
最終ジャッジ日時 2023-09-28 03:29:46
合計ジャッジ時間 5,309 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;

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