hdu 3065 AC自动机模版题】的更多相关文章

题意:输出每个模式串出现的次数,查询的时候呢使用一个数组进行记录就好. 同上题一样的关键点,其他没什么难度了. #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxw = 1000 * 50 + 10; const int sigma_size = 128; const int maxl = 2000000 + 10; char str[1010]…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3065 题目大意:多个模式串,范围是大写字母.匹配串的字符范围是(0~127).问匹配串中含有哪几种模式串,且每种模式串出现了多少次. 解题思路: AC自动机模板题.模式串的范围是大写字母,但是匹配串的范围却是(0~127). 如果Trie 开到 128 加上不回收内存,就会MLE. 实际上开到26就行了,find的时候对于c<0||c>26,强制令pos=root出现失配,并开始下一个字符就行了…
Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 59827    Accepted Submission(s): 19715 Problem Description In the modern time, Search engine came into the life of everybody lik…
所学的AC自动机都源于斌哥和昀神的想法. 题意:求目标串中出现了几个模式串. 使用一个int型的end数组记录,查询一次. #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxw = 50 * 10000 + 10; const int sigma_size = 26; const int maxl = 1000000 + 10; struct T…
题意:输出出现模式串的id,还是用end记录id就可以了. 本题有个关键点:“以上字符串中字符都是ASCII码可见字符(不包括回车).”  -----也就说AC自动机的Trie树需要128个单词分支. #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxw = 210 *500 + 10; const int sigma_size = 128; c…
中文题题意不再赘述 注意 失配数组 f  初始化一步到位 #include <stdio.h> #include <string.h> #include <queue> using namespace std; #define N 2000100 #define maxnode 50010 #define sigma_size 26 struct node{ char name[55]; int num; }S[1101]; struct Trie{ int ch[ma…
Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 70290    Accepted Submission(s): 23917 Problem Description In the modern time, Search engine came into the life of everybody lik…
// hdu 3065 AC自动机 // // 题目大意: // // 给你n个短串,然后给你一个长串,问:各个短串在长串中,出现了多少次 // // 解题思路: // // AC自动机,插入,构建,查询就OK啦 // // 感悟: // // 这道题真的是1A的哟~~~很开心~~~尽管是个裸地,继续加油哟~~~FIGHTING #include <cstdio> #include <cstring> #include <algorithm> #include <…
病毒侵袭持续中 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10324    Accepted Submission(s): 3633 Problem Description 小t非常感谢大家帮忙解决了他的上一个问题.然而病毒侵袭持续中.在小t的不懈努力下,他发现了网路中的“万恶之源”.这是一个庞大的病毒网站,他有着好多好多的病毒,但…
Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 57353    Accepted Submission(s): 18820 Problem Description In the modern time, Search engine came into the life of everybody li…