結果

問題 No.225 文字列変更(medium)
ユーザー kuc_jacksonkuc_jackson
提出日時 2021-05-02 13:30:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 625 bytes
コンパイル時間 2,186 ms
コンパイル使用メモリ 203,948 KB
実行使用メモリ 7,180 KB
最終ジャッジ日時 2023-09-28 03:34:39
合計ジャッジ時間 3,038 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,992 KB
testcase_01 WA -
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 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 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(N + 1, vector<int>(M + 1, 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++){
        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[N][M] << endl;
}
0