結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 4 ms
7,464 KB
testcase_04 AC 4 ms
7,372 KB
testcase_05 AC 3 ms
7,384 KB
testcase_06 WA -
testcase_07 AC 3 ms
7,412 KB
testcase_08 AC 4 ms
7,332 KB
testcase_09 AC 4 ms
7,336 KB
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};

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