結果

問題 No.225 文字列変更(medium)
ユーザー yomogyomog
提出日時 2021-07-27 13:08:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 1,011 bytes
コンパイル時間 1,547 ms
コンパイル使用メモリ 169,944 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2023-09-30 16:31:54
合計ジャッジ時間 2,681 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,996 KB
testcase_01 AC 8 ms
8,264 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 11 ms
9,920 KB
testcase_13 AC 11 ms
10,496 KB
testcase_14 AC 11 ms
10,448 KB
testcase_15 AC 10 ms
9,972 KB
testcase_16 AC 11 ms
10,344 KB
testcase_17 AC 10 ms
10,172 KB
testcase_18 AC 10 ms
9,904 KB
testcase_19 AC 11 ms
10,240 KB
testcase_20 AC 10 ms
9,656 KB
testcase_21 AC 10 ms
10,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
#define r(a, b, c, r, ...) r
#define r2(i, a, b) for(ll i = ll(a); i < ll(b); ++i)
#define r1(i, b) r2(i, 0, b)
#define rep(...) r(__VA_ARGS__, r2, r1)(__VA_ARGS__)
const ll INF = 1ll << 60;  // 1e18
const ll MOD = 1000000007;

int main() {
    {
        ll n;
        cin >> n;
        cin >> n;
    }
    string s, t;
    cin >> s >> t;
    vector<vll> d(s.size() + 1, vll(t.size() + 1, INF));
    d[0][0] = 0;
    rep(i, -1, s.size()) rep(j, -1, t.size()) {
        if(i != -1 && j != -1) {
            if(s[i] == t[j]) d[i + 1][j + 1] = min(d[i + 1][j + 1], d[i][j]);
            else
                d[i + 1][j + 1] = min(d[i + 1][j + 1], d[i][j] + 1);
        }
        if(i != -1) d[i + 1][j + 1] = min(d[i + 1][j + 1], d[i][j + 1] + 1);  // del
        if(j != -1) d[i + 1][j + 1] = min(d[i + 1][j + 1], d[i + 1][j] + 1);  // insert
    }
    cout << d[s.size()][t.size()] << endl;
}

0