結果

問題 No.225 文字列変更(medium)
ユーザー uw_yu1rabbituw_yu1rabbit
提出日時 2020-12-30 21:26:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 1,121 bytes
コンパイル時間 842 ms
コンパイル使用メモリ 83,744 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-16 22:01:31
合計ジャッジ時間 1,904 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,144 KB
testcase_01 AC 8 ms
8,192 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 10 ms
10,112 KB
testcase_13 AC 10 ms
10,752 KB
testcase_14 AC 9 ms
10,496 KB
testcase_15 AC 8 ms
10,240 KB
testcase_16 AC 9 ms
10,240 KB
testcase_17 AC 9 ms
10,240 KB
testcase_18 AC 8 ms
9,984 KB
testcase_19 AC 9 ms
10,240 KB
testcase_20 AC 8 ms
9,728 KB
testcase_21 AC 8 ms
10,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdint>
#include<cstddef>
#include<vector>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = size_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
template<typename T>
using vec = vector<T>;
#define rep(i, n) for (i64 i = 0; i < (i64)(n); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
void solve(){
}
int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    u64 n,m;
    cin >> n >> m;
    string s,t;
    cin >> s >> t;
    vec<vec<i64>> dp(n + 1,vec<i64>(m + 1,1e18));
    dp[0][0] = 0;
    rep(i,n + 1){
        rep(j, m + 1){
            if(i && j){
                if(s[i - 1] == t[j - 1])dp[i][j] = min(dp[i - 1][j - 1],dp[i][j]);
                else dp[i][j] = min(dp[i - 1][j - 1] + 1 ,dp[i][j]);
            }
            if(i)dp[i][j] = min(dp[i - 1][j] + 1 ,dp[i][j]);
            if(j)dp[i][j] = min(dp[i][j - 1] + 1,dp[i][j]);
        }
    }
    cout << dp.back().back() << endl;
}
0