Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13908 Accepted Submission(s): 4987
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.
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.
Your output should contain all the hat’s words, one per line, in alphabetical order.
a ahat hat hatword hziee word
Ignatius.L | We have carefully selected several similar problems for you:
题意:给你n个单词,处理到EOF。问这些单词中有几个单词是由两个拼接成的
思路:
用字典树,枚举每个单词,找到这个单词每个节点上的单词结尾标志,记录,然后检查剩下的单词出没出现在字典树上。
#include