//296MS 4400K 671 B G++
//map是个好东西啊,要什么字典树
//题目就是要找前缀后缀都在字典里的合成词
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
using namespace std;
string wo[50010];
int main()
{
// freopen("in","r",stdin);
// freopen("out","w",stdout);
int i,r,len,num=0;
string str,tmp;
map<string,bool> dic;
while(cin>>str)
{
dic[str]=true;
wo[num++]=str;
}
for(i=0;i<num;i++)
{
str.clear();
tmp.clear();
tmp=wo[i];
len=wo[i].size();
for(r=0;r<len-1;r++)
{
str+=wo[i][r];
tmp.erase(tmp.begin());
if( dic[str]==true && dic[tmp]==true )
{
cout<<wo[i]<<endl;
break;
}
}
}
return 0;
}
hdu 1247
最新推荐文章于 2019-07-25 20:37:28 发布