結果
| 問題 |
No.225 文字列変更(medium)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-15 23:01:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,030 bytes |
| コンパイル時間 | 1,219 ms |
| コンパイル使用メモリ | 102,748 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2024-11-26 06:24:30 |
| 合計ジャッジ時間 | 2,270 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 5 |
ソースコード
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()
struct Edge{
int to;
int weight;
Edge(int t, int w) : to(t), weight(w){ }
};
struct edge{
int from;
int to;
int weight;
edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;
template <class T>
inline bool chmin(T &a, T b){
if (a > b){
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T &a, T b){
if (a < b){
a = b;
return true;
}
return false;
}
template <class T>
T gcd(T a, T b){
if( b==0 ) return a;
return gcd(b, a%b);
}
template <class T>
T lcm(T a, T b){
return (a*b)/gcd(a,b);
}
int INF = 1e9+7;
vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n,m;
cin >> n >> m;
string s,t;
cin >> s >> t;
vector<vector<int>> dp(n+1,vector<int>(m+1,INF));
dp[0][0] = 0;
rep(i,n) rep(j,m){
if(s[i]==t[j]){
dp[i+1][j+1] = min(dp[i][j],min(dp[i+1][j]+1,dp[i][j+1]+1));
}
else{
chmin(dp[i+1][j+1],min(dp[i][j]+1,min(dp[i+1][j]+1,dp[i][j+1]+1)));
}
}
cout << dp[n][m] << endl;
}