結果
| 問題 | No.225 文字列変更(medium) |
| コンテスト | |
| ユーザー |
albicilla
|
| 提出日時 | 2015-06-14 11:45:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 841 bytes |
| コンパイル時間 | 559 ms |
| コンパイル使用メモリ | 72,872 KB |
| 実行使用メモリ | 7,296 KB |
| 最終ジャッジ日時 | 2024-07-06 20:06:21 |
| 合計ジャッジ時間 | 1,410 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 22 |
ソースコード
#include<cstdio>
#include<cmath>
#include<cstring>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<sstream>
#include<typeinfo>
#include<fstream>
using namespace std;
int n,m;
char s[1000],t[1000];
int dp[1001][1001];
void solve(){
for(int i=0;i<=n;i++){
for(int j=0;j<=m;j++){
if(s[i]==t[j]){
min(dp[i+1][j+1],dp[i][j]);
}
else if(s[i]!=t[j]){
min(dp[i+1][j+1],dp[i][j]+1);
}
dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
dp[i][j+1]= min(dp[i][j+1],dp[i][j]+1);
}
}
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>s[i];
}
for(int i=0;i<m;i++){
cin>>t[i];
}
solve();
cout<<dp[n][m]<<endl;
return 0;
}
albicilla