提交时间:2023-12-16 09:42:48

运行 ID: 116242

#include<bits/stdc++.h> #define int long long using namespace std; int a[202][202]; char s1[202] , s2[202]; int m , n; signed main(){ cin >> s1 >> s2; m = strlen(s1); n = strlen(s2); for(int i = 1;i <= m;i++) a[i][0] = i; for(int i = 1;i <= n;i++) a[0][i] = i; for(int i = 1;i <= m;i++) { for(int j = 1;j <= n;j++) { if(s1[i - 1] == s2[j - 1]) a[i][j] = a[i - 1][j - 1]; else a[i][j] = min(min(a[i - 1][j] , a[i][j - 1]) , a[i - 1][j - 1]) + 1; } } cout << a[m][n]; return 0; }