首页 > 代码库 > 字典树-HDOJ-1247-Hat’s Words
字典树-HDOJ-1247-Hat’s Words
Hat’s Words
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8482 Accepted Submission(s): 3053
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
大意:给定若干个字符串,找出这样的字符串——它可由其他两个字符串拼接得到。
分析:考虑两种特殊情况:
input-----
a
bc
ab
c
abc
output----
abc
input-----
b
ba
baab
baabb
output----
baabb
<script src="https://code.csdn.net/snippets/516355.js" type="text/javascript"></script>
字典树-HDOJ-1247-Hat’s Words
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。