//UVA10391CompoundWords
//#define LOCAL
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
const int MAXN = 120000 + 10;
string s[MAXN];
int main() {
map<string, int> Match;
int i = 0;
#ifdef LOCAL
freopen("UVA10391in.txt", "r", stdin);
freopen("UVA10391out.txt", "w", stdout);
#endif
while(cin >> s[i]) {
Match[s[i]] = 1;
i++;
}
for(int j = 0; j <= i; j++) {
for(int k = 1; k < s[j].length(); k++) {
string tmp1 = s[j].substr(0, k);
string tmp2 = s[j].substr(k, s[j].length() - k);
if(!Match[tmp1]) continue;
if(!Match[tmp2]) continue;
cout << s[j] << endl;
break;
}
}
return 0;
}
/*
a
alien
born
less
lien
never
nevertheless
new
newborn
the
zebra
*/
UVA10391CompoundWords
最新推荐文章于 2024-04-09 17:01:20 发布