HDU2222Keywords Search AC_自动机】的更多相关文章

http://blog.csdn.net/niushuai666/article/details/7002823 #include <iostream> #include <cstdio> #include <cstring> using namespace std; struct node{ int count; node *next[26],*fail; void Node(){ count = 0;fail = NULL; memset(next,NULL,siz…
//暴力,从每一行的开始处开始寻找要查询的字符 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ]; int main(){ while(gets(str)){ ; str[i]; ++i) if(str[i]=='A'){ if(strstr(str+i, "Apple") == str+i) p…
spoj 7258 Lexicographical Substring Search (后缀自动机) 题意:给出一个字符串,长度为90000.询问q次,每次回答一个k,求字典序第k小的子串. 解题思路:构造出sam后,类似splay求前驱的做法,不断的逼近答案.我们知道,sam里从s走到某一节点即为一个子串,所以我们在每个节点下记录一个cnt,表示该节点下,能走到的节点有多少个.那么我们在求第k小的子串时,就往下走,枚举当前节点下的26字母节点,若枚举到的节点的cnt+1>=k那么就往该节点走,…
http://acm.hust.edu.cn/vjudge/problem/16403 题意:给定n个单词,一个字符串,问字符串中出现了多少个单词.(若单词her,he,字符串aher中出现了两个单词) 题解: 每个单词末尾节点sum=1:find的时候每个点都顺着fail往上跳,加上该节点的sum,然后将这个sum清了:注意同一个单词出现多次只算一次. #include<cstdio> #include<cstdlib> #include<cstring> #incl…
[HDU2222]Keywords Search Problem Description In the modern time, Search engine came into the life of everybody like Google, Baidu, etc.Wiskey also wants to bring this feature to his image retrieval system.Every image have a long description, when use…
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=2222 题目: Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 56558    Accepted Submission(s): 18493 Problem Description In the mo…
Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 50435    Accepted Submission(s): 16233 Problem Description In the modern time, Search engine came into the life of everybody li…
题目连接:hdu_2222_Keywords Search 存个自己写的AC自动机 #include<cstdio> #include<cstring> #define F(i,a,b) for(int i=a;i<=b;i++) *,tyn=;//数量乘串长,类型数量 struct AC_automation{ int tr[AC_N][tyn],cnt[AC_N],Q[AC_N],fail[AC_N],tot; inline int getid(char x){retur…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 51758    Accepted Submission(s): 16671 Problem Description In the modern time, Search engine came into the life of everybody like Google, Baidu,…
Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 68211    Accepted Submission(s): 23017 Problem Description In the modern time, Search engine came into the life of everybody lik…