結果

問題 No.225 文字列変更(medium)
ユーザー IL_mstaIL_msta
提出日時 2015-08-16 17:03:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,286 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 7,428 KB
最終ジャッジ日時 2023-09-25 12:26:18
合計ジャッジ時間 1,985 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
const int LenMax = 1001;
int dp[LenMax][LenMax];
int LCS(string A,string B){
	int aLen = A.size();
	int bLen = B.size();
	for(int i = 0; i < aLen; ++i){
		dp[i][0] = 0;
	}
	for(int j = 0; j < bLen; ++j){
		dp[0][j] = 0;
	}
	for(int i = 1; i <= aLen; ++i){
		for(int j = 1; j <= bLen; ++j){
			if( A[i-1] == B[j-1] ){
				dp[i][j] = dp[i-1][j-1] + 1;
			}else{
				dp[i][j] = max( dp[i][j-1],dp[i-1][j-1] );
			}
		}
	}

	return dp[aLen][bLen];
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	int n,m;
	string S,T;
	cin>>n>>m>>S>>T;
	int Len;
	Len = LCS(S,T);

	int ans;
	if( S.size() > T.size() ){
		ans = S.size() - Len;
	}else{
		ans = T.size() - Len;
	}
	P(ans);
	return 0;
}
0