字典树-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 i

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.
 

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.
 

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



目录
相关文章
|
6月前
|
算法
light oj 1255 - Substring Frequency (KMP)
输入两个字符串,计算二串在一串中出现的次数。 裸裸的KMP,参考刘汝佳《算法竞赛入门经典训练指南》 P212 或数据结构。
17 1
|
算法 Python
LeetCode 1160. 拼写单词 Find Words That Can Be Formed by Characters
LeetCode 1160. 拼写单词 Find Words That Can Be Formed by Characters
LeetCode 1160. 拼写单词 Find Words That Can Be Formed by Characters
LeetCode 389. Find the Difference
给定两个字符串 s 和 t,它们只包含小写字母。 字符串 t 由字符串 s 随机重排,然后在随机位置添加一个字母。 请找出在 t 中被添加的字母。
84 0
LeetCode 389. Find the Difference
LeetCode 150. Evaluate Reverse Polish Notation
根据逆波兰表示法,求表达式的值。 有效的运算符包括 +, -, *, / 。每个运算对象可以是整数,也可以是另一个逆波兰表达式。
28 0
LeetCode 150. Evaluate Reverse Polish Notation
|
数据安全/隐私保护 C++ Python
LeetCode 804. Unique Morse Code Words
LeetCode 804. Unique Morse Code Words
52 0
|
算法 Linux 测试技术
【论文阅读】(2014)Combinatorial Benders’ Cuts for the Strip Packing Problem
【论文阅读】(2014)Combinatorial Benders’ Cuts for the Strip Packing Problem
183 0
【论文阅读】(2014)Combinatorial Benders’ Cuts for the Strip Packing Problem
Leetcode-Easy 804. Unique Morse Code Words
Leetcode-Easy 804. Unique Morse Code Words
74 0
Leetcode-Easy 804. Unique Morse Code Words
|
Web App开发 Java 数据安全/隐私保护
HDOJ(HDU) 1563 Find your present!(异或)
HDOJ(HDU) 1563 Find your present!(异或)
214 0
|
存储
HDOJ/HDU 2140 Michael Scofield's letter(字符转换~)
HDOJ/HDU 2140 Michael Scofield's letter(字符转换~)
64 0
LeetCode之Find the Difference
LeetCode之Find the Difference
96 0