蓝桥杯
作者:
zplzh
,
2024-04-10 20:03:22
,
所有人可见
,
阅读 9
#include <bits/stdc++.h>
#define int long long
#define rep(i,a,n) for(int i =a;i<=n;i++)
#define per(i,a,n) for(int i =n;i>=a;i--)
#define fs first
#define sc second
using namespace std;
const int N = 1005;
string sta[N],stb[N],a,b;
int f[N][N];
void solve(){
cin>>a>>b;
int lena = a.length(), lenb = b.length();
int aa=0,bb=0;
rep(i,0,lena-1){
if(a[i]>='A'&&a[i]<='Z') aa++;
sta[aa] +=a[i];
}
rep(i,0,lenb-1){
if(b[i]>='A'&&b[i]<='Z') bb++;
stb[bb] +=b[i];
}
rep(i,1,aa){
rep(j,1,bb){
if(sta[i]==stb[j]) f[i][j] = max(f[i][j],f[i-1][j-1]+1);
else f[i][j] = max(f[i-1][j],f[i][j-1]);
}
}
cout<<f[aa][bb]<<endl;
}
signed main(){
int t = 1;
//cin>>t;
while(t--) solve();
}