POJ 2001 Shortest Prefixes (Trie)】的更多相关文章

题目链接:POJ 2001 Description A prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", "ca", "car", "carb", "carbo", and "carbon"…
Shortest Prefixes 题意:输入不超过1000个字符串,每个字符串为小写字母,长度不超过20:之后输出每个字符串可以简写的最短前缀串: Sample Input carbohydrate cart carburetor caramel caribou carbonic cartilage carbon carriage carton car carbonate Sample Output carbohydrate carboh (carbo不止一个字符串含有,所以不能作为简写符号)…
Shortest Prefixes Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15574   Accepted: 6719 Description A prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", &qu…
Shortest Prefixes Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15610   Accepted: 6734 Description A prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", &qu…
1.链接地址: http://bailian.openjudge.cn/practice/2001 http://poj.org/problem?id=2001 2.题目: Shortest Prefixes Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12208   Accepted: 5210 Description A prefix of a string is a substring starting at t…
Shortest Prefixes Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12731   Accepted: 5442 Description A prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", &qu…
题目地址:POJ 2001 考察的字典树,利用的是建树时将每个点仅仅要走过就累加.最后从根节点開始遍历,当遍历到仅仅有1次走过的时候,就说明这个地方是最短的独立前缀.然后记录下长度,输出就可以. 代码例如以下: #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <ctype.h&g…
Shortest Prefixes Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21651   Accepted: 9277 Description A prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", &qu…
<题目链接> 题目大意: 找出能唯一标示一个字符串的最短前缀,如果找不出,就输出该字符串. 解题分析: Trie树的简单应用,对于每个单词的插入,都在相应字符对应的节点 num 值+1 ,这样在查询的时候,如果遍历到num值为1的节点,就可以确定,该前缀能够唯一确定一个字符串,或者是一直遍历到NULL,这时直接输出它本身即可. 指针式Trie树: #include <cstdio> #include <cstring> #include <algorithm>…
主题链接:http://poj.org/problem?id=2001 Description A prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", "ca", "car", "carb", "carbo",…