結果

問題 No.225 文字列変更(medium)
ユーザー latte0119latte0119
提出日時 2016-02-25 14:16:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 998 bytes
コンパイル時間 1,204 ms
コンパイル使用メモリ 160,508 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2023-10-23 19:59:45
合計ジャッジ時間 2,465 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 7 ms
8,444 KB
testcase_02 AC 3 ms
8,440 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 3 ms
8,440 KB
testcase_06 AC 3 ms
8,440 KB
testcase_07 WA -
testcase_08 AC 3 ms
8,440 KB
testcase_09 AC 3 ms
8,440 KB
testcase_10 WA -
testcase_11 AC 3 ms
8,440 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 9 ms
8,444 KB
testcase_15 WA -
testcase_16 AC 9 ms
8,444 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 9 ms
8,444 KB
testcase_20 WA -
testcase_21 AC 9 ms
8,444 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<N)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