結果
| 問題 |
No.225 文字列変更(medium)
|
| コンテスト | |
| ユーザー |
reew2n
|
| 提出日時 | 2015-06-12 23:05:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 962 bytes |
| コンパイル時間 | 1,276 ms |
| コンパイル使用メモリ | 158,984 KB |
| 実行使用メモリ | 7,552 KB |
| 最終ジャッジ日時 | 2024-07-06 15:56:06 |
| 合計ジャッジ時間 | 1,949 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 11 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define F first
#define S second
#define PB(a) push_back(a)
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef pair<int,long double> pr;
typedef pair<pr,int> ppr;
typedef priority_queue<pr,vector<pr>,greater<pr> > PQ;
typedef vector<pr> Vpr;
typedef vector<LL> VI;
typedef complex<LL> cld;
typedef vector<cld> Vcld;
typedef map<pr,int> MP;
const int SIZE=100010;
const LL INF=1<<28;
string a,b;
int DP[1001][1001];
int solve(int x,int y){
if(DP[x][y]) return DP[x][y];
if(x||y){
if(x==0) return DP[x][y]=solve(x,y-1)+1;
if(y==0) return DP[x][y]=solve(x-1,y)+1;
if(a[x]==b[y]) return DP[x][y]=solve(x-1,y-1);
return DP[x][y]=min(solve(x,y-1),min(solve(x-1,y-1),solve(x-1,y)))+1;
}
return 0;
}
int main(){
int x,y;
cin >> x>>y;
cin >> a >> b;
cout << solve(a.size()-1,b.size()-1) << endl;
return 0;
}
reew2n