結果

問題 No.225 文字列変更(medium)
ユーザー Genki TakahashiGenki Takahashi
提出日時 2021-07-19 15:24:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 164,608 KB
実行使用メモリ 7,608 KB
最終ジャッジ日時 2023-09-24 12:15:08
合計ジャッジ時間 2,435 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 3 ms
7,320 KB
testcase_03 AC 3 ms
7,320 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
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>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
const double PI = 3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = 1LL << 50;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};
const int ddx[] = {0,1,0,-1,1,1,-1,-1}, ddy[] = {1,0,-1,0,1,-1,1,-1};


const int inf = 1<<23;
int main() {
    string  S,T;
    int n,m;
    cin >> n >> m;
    cin >> S >> T;
    int dp[1010][1010];
    memset(dp, inf, sizeof(dp));
    dp[0][0] = 0;
    rep(i,S.size()) {
        rep(j, T.size()) {
            if(S[i]==T[j]) dp[i+1][j+1] = dp[i][j];
            else dp[i+1][j+1] = min(min(dp[i+1][j] + 1,dp[i][j+1] + 1), dp[i][j]+1);
        }
    }
    cout << dp[S.size()][T.size()] << endl;
    return 0;
}
0