結果

問題 No.225 文字列変更(medium)
ユーザー reew2nreew2n
提出日時 2015-06-12 22:56:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 958 bytes
コンパイル時間 1,140 ms
コンパイル使用メモリ 144,504 KB
実行使用メモリ 7,620 KB
最終ジャッジ日時 2023-09-20 21:07:52
合計ジャッジ時間 2,225 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 21 ms
7,336 KB
testcase_14 WA -
testcase_15 AC 13 ms
7,060 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 18 ms
6,968 KB
testcase_21 AC 20 ms
7,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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) return DP[x][y]=solve(x,y-1)+1;
    if(!y) 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;
}
0