如题
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
void qazwsx()
{
ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
}
int f[100000][100000],n,m;
int main(){
qazwsx();
char x[100000],y[100000];
scanf("%s%s",x+1,y+1);
n=strlen(x+1);
m=strlen(y+1);
for(int i=1;i<=n;i++)f[i][0]=i;
for(int i=1;i<=m;i++)f[0][i]=i;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(x[i]==y[j])
{
f[i][j]=f[i-1][j-1];
}
else
{
f[i][j]=min(min(f[i-1][j-1],f[i][j-1]),f[i-1][j])+1;
}
}
}
cout<<f[n][m];
return 0;
}