#include<iostream>
#include<string>
#include<vector>
using namespace std;
/* 最长公共字串(连续) */
int longestSubstring(string x,string y){
int Length1 = x.length();
int Length2 = y.length();
vector<vector<int>> dp(Length1 + 1,vector<int>(Length2 + 1,0));
int Max = 0;
for(int i = 1;i <= Length1;i ++){
for(int j = 1;j <= Length2;j ++){
if(x[i - 1] != y[j - 1]){
dp[i][j] = 0;
}
else if(x[i - 1] == y[j - 1]){
dp[i][j] = dp[i - 1][j - 1] + 1;
}
Max = max(Max,dp[i][j]);
}
}
return Max;
}
/* 最长公共子序列(不连续)*/
int longestSubstring(string x,string y){
int Length1 = x.length();
int Length2 = y.length();
vector<vector<int>> dp(Length1 +1,vector<int>(Length2 + 1,0));
for(int i = 1;i <= Length1;i ++){
for(int j = 1;j <= Length2;j ++){
if(x[i] == y[j])
{
dp[i][j] = dp[i - 1][j - 1] + 1;
}
else{
dp[i][j] = max(dp[i - 1][j],dp[i][j - 1]);
}
}
}
return dp[Length1][Length2];
}