nint4528
Rating
-
Bài tập
0
Điểm
0
Rating #
-
Điểm #
31839
Giới thiệu
include <bits/stdc++.h>
define N 10000
define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define form tungninh:))))
using namespace std;
string X, Y;
int dp[N+3][N+3];
int m, n;
int main()
{
fast;
freopen("CAU1.INP","r",stdin);
freopen("CAU1.OUT","w",stdout);
cin >> X >> Y;
m = X.size();
n = Y.size();
X = " "+X;
Y = " "+Y;
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
{
if(i==0||j==0)
dp[i][j]=0;
if(X[i] == Y[j])
dp[i][j]=dp[i-1][j-1];
else
dp[i][j]= min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
}
cout << dp[m][n] << endl;
return 0;
}