题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1251
题目概述:
给你一些单词和一些询问,对于每个询问求出所有单词中以询问为前缀的单词个数。
大致思路:
稍微修改一下Tire树就好了,对每个节点增加一个标记来记录到这个节点共有几个单词,这个题还需要注意用g++提交指针版的会MLE,所以需要用数组形式的Tire树。
年轻的我还是被输入给坑了……果然naive.
代码:
1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include