結果
問題 | No.225 文字列変更(medium) |
ユーザー |
![]() |
提出日時 | 2015-07-25 03:08:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 814 ms |
コンパイル使用メモリ | 81,968 KB |
実行使用メモリ | 7,424 KB |
最終ジャッジ日時 | 2024-12-24 10:41:07 |
合計ジャッジ時間 | 1,559 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#include<sstream> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<string> #include<vector> #include<set> #include<map> #include<queue> #include<numeric> #include<functional> #include<algorithm> #include<bitset> using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) #define indexOf(v,x) (find(all(v),x)-v.begin()) int dp[1001][1001]; int main(){ int n,m; string s,t; cin>>n>>m; cin>>s>>t; fill(dp[0],dp[1001],INF); dp[0][0]=0; rep(i,n+1)rep(j,m+1){ if(i<n&&j<m)dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+(s[i]!=t[j])); if(i<n)dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1); if(j<m)dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1); } cout<<dp[n][m]<<endl; return 0; }