题意:给出一系列单词,查询是否存在单词由另外两个单词构成
题解:映射保存单词是否出现
</pre><pre name="code" class="cpp">#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#define INF 0x3f3f3f3f
#define maxn 130100
#define mem(a) memset(a,0,sizeof(a))
using namespace std;
typedef long long ll;
char s[maxn][33];
int main()
{
int t,c = 1,n,k = 0;
//scanf("%d",&t);
map<string,int> Map;
while(scanf("%s",s[k++]) != EOF)
Map[s[k-1]] = 1;
for(int i = 0; i < k; i++)
{
int len = strlen(s[i]);
for(int j = 1; j < len; j++)
{
char s1[33] = "\0";
char s2[33] = "\0";
strncpy(s1,s[i],j);
strncpy(s2,s[i]+j,len-j);
if(Map[s1] && Map[s2])
{
printf("%s\n",s[i]);
break;
}
}
}
return 0;
}