結果
問題 | No.225 文字列変更(medium) |
ユーザー |
![]() |
提出日時 | 2016-02-25 14:22:37 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 12 ms / 5,000 ms |
コード長 | 997 bytes |
コンパイル時間 | 1,313 ms |
コンパイル使用メモリ | 160,516 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-12-24 10:49:16 |
合計ジャッジ時間 | 2,254 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#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; }