#include<iostream>
#include<map>
#include<string>
using namespace std;
const int maxn = 120005;
string word[maxn];
map<string, int>mp;
int main()
{
int cnt = 0;
while(cin >> word[cnt])
{
mp[word[cnt]]++;
cnt++;
}
for (int i = 0; i < cnt; i++)
{
for (int j = 0; j < word[i].length() - 1; j++)
{
string temp = word[i].substr(0, j);
string temp2 = word[i].substr(j,word[i].length());
if(mp[temp] && mp[temp2])
{
cout << word[i] <<endl;
break;
}
}
}
}
UVA-10391 Compound Words【string+map】
最新推荐文章于 2020-08-23 20:20:06 发布