题意: 给出n个资源串,m个病毒串,现在要如何连接资源串使得不含病毒串(可以重叠,样例就是重叠的). 题解: 这题的套路和之前的很不同了,之前的AC自动机+DP的题目一般都是通过teir图去转移, 这题有点小不同,认真分析这一题,我们可以知道n个资源串,m个病毒串在AC自动机的上面是哪一个节点 所以可以根据teir图去处理出每一个资源串的节点不经过病毒串节点的最短距离,这个可以通过BFS实现. 这个一开始要处理AC自动机上的root节点,毕竟是从root节点开始走的. 处理出了每个点到其他点的最…
题意:给你两个串,求用m个R,n个D能组成多少个包含这两个串 题解:先构造一个AC自动机记录每个状态包含两个串的状态, 状态很容易定义 dp[i][j][k][status]表示在AC自动机K这个节点 使用了 i 个D,j个R ,状态为status的方案数. 然后直接DP即可. #include <set> #include <map> #include <stack> #include <queue> #include <cmath> #inc…
题意:给定 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…
Great! Your new software is almost finished! The only thing left to do is archiving all your n resource files into a big one. Wait a minute… you realized that it isn’t as easy as you thought. Think about the virus killers. They’ll find your software…
HDU 4856 Tunnels 题目链接 题意:给定一些管道.然后管道之间走是不用时间的,陆地上有障碍.陆地上走一步花费时间1,求遍历全部管道须要的最短时间.每一个管道仅仅能走一次 思路:先BFS预处理出两两管道的距离.然后状态压缩DP求解,dp[s][i]表示状态s.停在管道i时候的最小花费 代码: #include <cstdio> #include <cstring> #include <queue> #include <algorithm> usi…
Resource Archiver Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others)Total Submission(s): 2382    Accepted Submission(s): 750 Problem Description Great! Your new software is almost finished! The only thing left to…
Wireless Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5640    Accepted Submission(s): 1785 Problem Description Liyuan lives in a old apartment. One day, he suddenly found that there…
// hdu 2896 AC自动机 // // 题目大意: // // 给你n个短串,然后给你q串长字符串,要求每个长字符串中 // 是否出现短串,出现的短串各是什么 // // 解题思路: // // AC自动机,插入单词,构建自动机,然后查询就可以了. // // 感悟: // // 哎,自己AC自动机果然刚学,还只会个模板,自动机构没构建 // 都不知道...继续加油吧~~~FIGHTING! #include <cstdio> #include <cstring> #inc…
// hdu 3065 AC自动机 // // 题目大意: // // 给你n个短串,然后给你一个长串,问:各个短串在长串中,出现了多少次 // // 解题思路: // // AC自动机,插入,构建,查询就OK啦 // // 感悟: // // 这道题真的是1A的哟~~~很开心~~~尽管是个裸地,继续加油哟~~~FIGHTING #include <cstdio> #include <cstring> #include <algorithm> #include <…