#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
using namespace std;
int testcase;
const int MAXLEN = 60;
vector<string> strlist;
set<string> myset;
int n;
string getans(){
// iterate on the first string , and look up in the else strings;
myset.clear();
string s = strlist[0];
bool flag;
for (int len = MAXLEN; len>= 3 ; --len) {
for (int ix = 0; ix <=MAXLEN-len ; ++ix) {
flag = true;
string temp = s.substr(ix, len);
for (int i = 1; i < strlist.size(); ++i) {
if (string::npos == strlist[i].find(temp)){
flag = false;
break;
}
}
if (flag){
myset.insert(temp);
}
}
if (!myset.empty()){
return *(myset.begin());
}
}
return "no significant commonalities";
}
int main(){
cin>>testcase;
while (testcase--){
cin>>n;
string s;
for (int i = 0; i < n; ++i) {
cin>>s;
strlist.push_back(s);
}
cout<<getans()<<endl;
strlist.clear();
}
}
POJ 3080
最新推荐文章于 2019-09-27 19:05:10 发布