提交时间:2023-12-16 09:18:52
运行 ID: 116215
#include<bits/stdc++.h> using namespace std; const int maxn = 1e2+1e3; string s,t; int f[maxn][maxn]; signed main() { cin >> s >> t; int len1 = s.size(); int len2 = t.size(); for(int i = 1;i <= len1;i++) { for(int j = 1;j <= len2;j++) { f[i][j] = max(f[i-1][j],f[i][j-1]); if(s[i-1] == t[j-1]) f[i][j] = max(f[i][j],f[i-1][j-1]+1); } } cout <<len1+len2-f[len1][len2]* 2; return 0; }