結果

問題 No.225 文字列変更(medium)
ユーザー latte0119latte0119
提出日時 2016-02-25 14:22:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 997 bytes
コンパイル時間 1,161 ms
コンパイル使用メモリ 144,764 KB
実行使用メモリ 8,384 KB
最終ジャッジ日時 2023-08-25 23:06:35
合計ジャッジ時間 1,943 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
8,184 KB
testcase_01 AC 7 ms
8,184 KB
testcase_02 AC 4 ms
8,216 KB
testcase_03 AC 3 ms
8,120 KB
testcase_04 AC 3 ms
8,172 KB
testcase_05 AC 4 ms
8,180 KB
testcase_06 AC 4 ms
8,140 KB
testcase_07 AC 4 ms
8,180 KB
testcase_08 AC 3 ms
8,212 KB
testcase_09 AC 4 ms
8,224 KB
testcase_10 AC 4 ms
8,384 KB
testcase_11 AC 4 ms
8,220 KB
testcase_12 AC 8 ms
8,188 KB
testcase_13 AC 9 ms
8,140 KB
testcase_14 AC 9 ms
8,184 KB
testcase_15 AC 10 ms
8,224 KB
testcase_16 AC 9 ms
8,128 KB
testcase_17 AC 9 ms
8,220 KB
testcase_18 AC 10 ms
8,300 KB
testcase_19 AC 9 ms
8,216 KB
testcase_20 AC 9 ms
8,168 KB
testcase_21 AC 8 ms
8,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//#define int long long

typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ln <<endl
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N,M;
string S,T;

int dp[1111][1111];

signed main(){
    fill_n(*dp,1111*1111,1<<25);
    dp[0][0]=0;
    cin>>N>>M>>S>>T;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=M;j++){
            if(i<N&&j<M)chmin(dp[i+1][j+1],dp[i][j]+(S[i]!=T[j]));
            if(i<N)chmin(dp[i+1][j],dp[i][j]+1);
            if(j<M)chmin(dp[i][j+1],dp[i][j]+1);
        }
    }
    cout<<dp[N][M]<<endl;
    return 0;
}
0