字典树
柠檬不酸只是萌
遇 见 最 美 的 自 己 。
展开
-
HDU 1671 — Phone List
原题:http://acm.hdu.edu.cn/showproblem.php?pid=1671 题意: 给出一些号码,如果其中一个号码是另一个的前缀,则输出NO; 思路: 插入每个号码时,内部数字val = 0,最后一个数字val = 1; #include #include #define MAX 26 const int maxnode = 4000*100原创 2015-08-16 10:31:51 · 427 阅读 · 0 评论 -
HDU 1251 — 统计难题
原题:http://acm.hdu.edu.cn/showproblem.php?pid=1251 题意: 给出一些单词; 下面给出一些字符串,计算以该字符串为前缀的单词个数; 思路: 字典树模板题,只要在插入单词的时候每个字母所路过的节点的val都+1; #include #include #define MAX 26 const int maxnode=4000*原创 2015-08-15 19:45:13 · 424 阅读 · 0 评论