【UVA】10391 Compound Words(STL map)

题目

题目
 


 

分析

自认已经很简洁了,虽说牺牲了一些效率
 


 

代码

#include <bits/stdc++.h>
using namespace std;
set <string> m;
string s[120003];
int main()
{
	int n;
	while(cin>>s[n]) m.insert(s[n++]);
	for(int i=0;i<n;i++)
	{
		int l=s[i].length();
		for(int j=1;j<l;j++)
			if(m.count(s[i].substr(0,j))&&m.count(s[i].substr(j,l-j)))
			{
				cout<<s[i]<<endl;break;
			}
	}
	return 0;
}
posted @ 2017-11-26 00:32  noble_(noblex)  阅读(167)  评论(0编辑  收藏  举报
/* */