题目链接:Resource Archiver 解析:n个正常的串.m个病毒串,问包括全部正常串(可重叠)且不包括不论什么病毒串的字符串的最小长度为多少. AC自己主动机 + bfs + 状态压缩DP 用最短路预处理出状态的转移.能够优化非常多 AC代码: #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <queue> us…
题意:给定 n 个文本串,m个病毒串,文本串重叠部分可以合并,但合并后不能含有病毒串,问所有文本串合并后最短多长. 析:先把所有的文本串和病毒都插入到AC自动机上,不过标记不一样,可以给病毒标记-1,如果访问知道就知道不可行的,然后处理出两两串叠加的最小长度,这个要用bfs,在AC自动机上把这个处理出来,然后剩下的就是一个简单的DP了,dp[s][i] 表示状态为 s 时,i 串在后面,长度最短是多少. 代码如下: #pragma comment(linker, "/STACK:10240000…
\(\quad\)Great! Your new software is almost finished! The only thing left to do is archiving all your n resource files into a big one. \(\quad\)Wait a minute- you realized that it isn't as easy as you thought. Think about the virus killers. They'll f…
http://poj.org/problem?id=3691 http://acm.hdu.edu.cn/showproblem.php?pid=2457 DNA repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5690   Accepted: 2669 Description Biologists finally invent techniques of repairing DNA that contain…
pid=2825">http://acm.hdu.edu.cn/showproblem.php? pid=2825 Wireless Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4560    Accepted Submission(s): 1381 Problem Description Liyuan li…
pid=2896">http://acm.hdu.edu.cn/showproblem.php?pid=2896 病毒侵袭 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 11796    Accepted Submission(s): 3067 Problem Description 当太阳的光辉逐渐被月亮遮蔽.世界失去了光明,…
点击打开链接题目链接 Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 42838    Accepted Submission(s): 13488 Problem Description In the modern time, Search engine came into the life of eve…
本题是在text里面查找key word的增强版.由于这里有多个text. 那么就不能够简单把Trie的叶子标志记录改动成-1进行加速了,能够使用其它技术.我直接使用个vis数组记录已经訪问过的节点,达到加速效果,速度还算挺快的. 只是看discuss里面有人直接使用Trie,做出了140ms的速度,并且他的程序严格来说并不对.可见本题的数据非常水啊.Trie的时间效率肯定比AC自己主动机低,可是在数据非常水的特殊情况下.Trie的速度也能够非常快的. 注意两个细节: 1 病毒也须要安装顺序输出…
Description Liyuan lives in a old apartment. One day, he suddenly found that there was a wireless network in the building. Liyuan did not know the password of the network, but he got some important information from his neighbor. He knew the password…
单词统计的题目,给出一些单词,统计有多少单词在一个文本中出现,最经典的入门题了. AC自己主动机的基础: 1 Trie. 以这个数据结构为基础的,只是添加一个fail指针和构造fail的函数 2 KMP,不是直接运用KMP.而是须要KMP的思想.KMP思想都没有的话,理解这个算法会更加吃力的. 注意本题的单词会有反复出现的,一个单词仅仅能统计一次. 搜索了一下网上的题解.发现好多代码都是一大抄的啊.⊙﹏⊙b汗. 本博客的乃是原创代码.代码风格也是几乎相同固定的,转载请注明出处:http://bl…