Problem #1805 - ECNU Online Judge
#include <bits/stdc++.h>
using namespace std;
int main() {
string str1, str2;
cin >> str1 >> str2;
int dp[str1.size()+1];
memset(dp,0,sizeof(dp));
int ans=0;
for(int j=0;j<str2.length();j++){
for(int i=str1.length()-1;i>=0;i--){
if(str1[i]==str2[j]) dp[i+1]=dp[i]+1;
else dp[i+1]=0;
if(dp[i+1]>ans) ans=dp[i+1];
}
}
cout<<ans;
}