結果
| 問題 |
No.225 文字列変更(medium)
|
| コンテスト | |
| ユーザー |
IL_msta
|
| 提出日時 | 2015-08-16 17:03:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,286 bytes |
| コンパイル時間 | 643 ms |
| コンパイル使用メモリ | 88,016 KB |
| 実行使用メモリ | 7,344 KB |
| 最終ジャッジ日時 | 2024-07-18 09:53:48 |
| 合計ジャッジ時間 | 1,508 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 17 |
ソースコード
#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;
}
IL_msta