Hat’s Words
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8343 Accepted Submission(s): 3004
Problem Description
A hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.
You are to find all the hat’s words in a dictionary.
You are to find all the hat’s words in a dictionary.
Input
Standard
input consists of a number of lowercase words, one per line, in
alphabetical order. There will be no more than 50,000 words.
Only one case.
Only one case.
Output
Your output should contain all the hat’s words, one per line, in alphabetical order.
Sample Input
a
ahat
hat
hatword
hziee
word
Sample Output
ahat
hatword
Author
戴帽子的
简述题意: 给你很多单词,查找能够由其中的两个单词拼合而成的单词,并按字典序输出.....
代码:
1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 typedef struct node 5 { 6 struct node *child[26]; 7 bool tail; 8 }Trie; 9 char mat[50005][15]; 10 void Insert(char *s,Trie *root) 11 { 12 int i,pos,j; 13 Trie *cur=root,*curnew; 14 for(i=0;s[i]!='