結果
問題 | No.225 文字列変更(medium) |
ユーザー |
|
提出日時 | 2020-02-28 06:41:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 5,000 ms |
コード長 | 456 bytes |
コンパイル時間 | 513 ms |
コンパイル使用メモリ | 67,572 KB |
実行使用メモリ | 7,424 KB |
最終ジャッジ日時 | 2024-10-13 16:20:31 |
合計ジャッジ時間 | 1,534 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int N,M; string s,t; int dp[1010][1010]; main() { cin>>N>>M>>s>>t; for(int i=0;i<=N;i++)for(int j=0;j<=M;j++)dp[i][j]=1145141919; dp[0][0]=0; for(int i=0;i<=N;i++)for(int j=0;j<=M;j++) { 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; }