POJ - 3080 Blue Jeans (暴力截取)
#include<iostream>
using namespace std;
string s[11],str;
int main()
{
int t,n;cin>>t;while(t--){
string ss="no significant commonalities";cin>>n;for(int i=1;i<=n;i++) cin>>s[i];for(int k=3;k<=60;k++)for(int i=0;i<=60-k;i++){
str=s[1].substr(i,k);int flag=0;for(int j=2;j<=n;j++) if(s[j].find(str)==string::npos){
flag=1;break;} if(flag) continue;else {
if(ss=="no significant commonalities")ss=str;else if(ss.size()<str.size())ss=str;else if(ss.size()==str.size())ss=min(ss,str);}}cout<<ss<<endl;}return 0;
}