提交时间:2023-11-25 10:32:56
运行 ID: 112118
#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 << f[len1][len2]; return 0; }