結果
問題 | No.225 文字列変更(medium) |
ユーザー | reew2n |
提出日時 | 2015-06-12 23:11:17 |
言語 | C++11 (gcc 13.3.0) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 992 bytes |
コンパイル時間 | 1,489 ms |
コンパイル使用メモリ | 159,344 KB |
実行使用メモリ | 7,552 KB |
最終ジャッジ日時 | 2024-12-24 10:09:45 |
合計ジャッジ時間 | 2,819 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 RE * 1 |
ソースコード
#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+1][y+1]) return DP[x+1][y+1]; if(x!=-1||y!=-1){ if(x==-1) return DP[x+1][y+1]=solve(x,y-1)+1; if(y==-1) return DP[x+1][y+1]=solve(x-1,y)+1; if(a[x]==b[y]) return DP[x+1][y+1]=solve(x-1,y-1); return DP[x+1][y+1]=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(),b.size()) << endl; return 0; }