結果

問題 No.225 文字列変更(medium)
ユーザー reew2nreew2n
提出日時 2015-06-12 23:11:17
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 992 bytes
コンパイル時間 1,084 ms
コンパイル使用メモリ 144,844 KB
実行使用メモリ 7,336 KB
最終ジャッジ日時 2023-08-25 22:45:12
合計ジャッジ時間 2,380 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
5,028 KB
testcase_01 RE -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 18 ms
7,024 KB
testcase_13 AC 18 ms
7,316 KB
testcase_14 AC 18 ms
7,336 KB
testcase_15 AC 12 ms
7,080 KB
testcase_16 AC 18 ms
7,284 KB
testcase_17 AC 12 ms
7,032 KB
testcase_18 AC 15 ms
6,976 KB
testcase_19 AC 18 ms
7,236 KB
testcase_20 AC 16 ms
7,080 KB
testcase_21 AC 16 ms
7,184 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+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;
}
0