555

#include<bits/stdc++.h>
using namespace std;
const int N = 1001;
int dp[N][N];
string str1,str2;
int LIS(){
    for(int i=1;i<=str1.length();i++)
        for(int j=1;j<=str2.length();j++)
            if(str1[i-1]==str2[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    return dp[str1.length()][str2.length()];
}
int main(){
    cin>>str1>>str2;
    cout<<LIS()<<endl;
    return 0;
}

 

posted @ 2021-04-27 22:25  limited_Infinite  阅读(31)  评论(0编辑  收藏  举报
// //返回顶部 //返回顶部按钮