linux怎么查看本机内存大小
230
2022-10-24
hdu 1247 (字典树入门)
Hat’s Words
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12149 Accepted Submission(s): 4338
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
题意:找出能有已知给定两个单词组成的单词。思路:先插入每个单词进入字典树,然后分别对每个单词进行查找,find找到前缀后再利用find2找到后缀,当后缀对应某个单词时,则证明此单词由两个字典中单词组成注意输入到文件尾
package 字典树;
import java.util.Scanner;
class Trie{
private Node root;
public Trie() {
root = new Node();
}
public void insert(String s){
Node t =root;
for(int i=0;i
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~