hdu 4117 GRE Words AC自动机DP】的更多相关文章

题目:给出n个串,问最多能够选出多少个串,使得前面串是后面串的子串(按照输入顺序) 分析: 其实这题是这题SPOJ 7758. Growing Strings AC自动机DP的进阶版本,主题思想差不多. 对于这题来说,需要离线操作.dp转移也是很显然. 但是由于数据比较大,所以普通的沿着fail指针往上走,逐步更新答案会TLE. 考虑把fail指针反向,由于ac自动机的每个节点均有唯一的fail指针,若是沿着fail指针往上走,显然都会走到root,所以反向之后显然是一棵树,不妨称之为fail树…
题目链接 problem Recently George is preparing for the Graduate Record Examinations (GRE for short). Obviously the most important thing is reciting the words. Now George is working on a word list containing N words. He has so poor a memory that it is too…
Ring Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1564    Accepted Submission(s): 487 Problem Description For the hope of a forever love, Steven is planning to send a ring to Jane with a roma…
题意:给N个串,一个大串,要求在最小的改变代价下,得到一个不含上述n个串的大串. 思路:dp,f[i][j]代表大串中第i位,AC自动机上第j位的最小代价. #include<algorithm> #include<cstdio> #include<cmath> #include<cstring> #include<iostream> #include<queue> std::queue<int>Q; ][],end[],…
题目链接 做题, #include <cstdio> #include <string> #include <cstring> using namespace std; #define MOD 20090717 ][]; ]; ]; ]; ][][]; ]; int t; void CL() { memset(trie,-,sizeof(trie)); memset(dp,,sizeof(dp)); memset(o,,sizeof(o)); t = ; } void…
DNA repair Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 940    Accepted Submission(s): 500 Problem Description Biologists finally invent techniques of repairing DNA that contains segments cau…
Lost's revenge Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 3757    Accepted Submission(s): 1020 Problem Description Lost and AekdyCoin are friends. They always play "number game"(A bor…
Ring Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3180    Accepted Submission(s): 1033 Problem Description For the hope of a forever love, Steven is planning to send a ring to Jane with a rom…
题意:给你几个模式串,问你主串最少改几个字符能够使主串不包含模式串 思路:从昨天中午开始研究,研究到现在终于看懂了.既然是多模匹配,我们是要用到AC自动机的.我们把主串放到AC自动机上跑,并保证不出现模式串,这里对AC自动机的创建有所改动,我们需要修改不存在但是符合要求的节点,如果某节点的某一子节点不存在,我们就把这个子节点指向他父辈节点存在的该节点(比如k->next[1]不存在,k->fail->next[1]存在,我们就把他改为k->next[1] = k->fail-…
题意:容易理解... 分析:这是一道比较简单的ac自动机+dp的题了,直接上代码. 代码实现: #include<stdio.h> #include<string.h> #include<stdlib.h> #include<iostream> #include<queue> using namespace std; struct node{ ]; int fail; int flag; void init() { memset(next,,si…