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…
题目链接:https://vjudge.net/problem/HDU-2825 Wireless Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7733    Accepted Submission(s): 2509 Problem Description Liyuan lives in a old apartmen…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5400    Accepted Submission(s): 1704 Problem Description Liyuan lives in a old apartment. One day, he suddenly found that there was a wireless ne…
题目链接 BZOJ1559 题解 考虑到这是一个包含子串的问题,而且子串非常少,我们考虑\(AC\)自动机上的状压\(dp\) 设\(f[i][j][s]\)表示长度为\(i\)的串,匹配到了\(AC\)自动机\(j\)号节点,且已匹配集合为\(s\)的方案数 直接在\(AC\)自动机上转移即可 但是为了防止使用\(last\)指针之类的,计算匹配的串,我们先将原串的集合去重和去包含关系 方案怎么办? 考虑到\(ans \le 42\),一定是刚好若干个原串以最长前后缀相同的方式相接 因为如果不…
题意:目标串n( <= 10)个,病毒串m( < 1000)个,问包含所有目标串无病毒串的最小长度 思路:貌似是个简单的状压DP + AC自动机,但是发现dp[1 << n][5e4]根本开不出那么多空间,似乎GG.但是我们仔细想一下就能发现,既然要包含所有目标串的最小长度,那必然这个串就是只有目标串叠加组成的,只是在叠加的过程中我们不能混入病毒串.所以其实Trie树上有用的点最多就10个,我们只要处理出所有目标串之间"最小有效转化"就行了,那么空间为dp[1…
Time Limit: 10 Seconds      Memory Limit: 65536 KB Dr. X is a biologist, who likes rabbits very much and can do everything for them. 2012 is coming, and Dr. X wants to take some rabbits to Noah's Ark, or there are no rabbits any more. A rabbit's gene…
题目链接 Problem Description Dr. X is a biologist, who likes rabbits very much and can do everything for them. 2012 is coming, and Dr. X wants to take some rabbits to Noah's Ark, or there are no rabbits any more. A rabbit's genes can be expressed as a st…
Wireless Password Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u 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…
题意:m个密码串,问你长度为n的至少含有k个不同密码串的密码有几个 思路:状压一下,在build的时候处理fail的时候要用 | 把所有的后缀都加上. 代码: #include<cmath> #include<set> #include<map> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include <iostream…
给你m个字符串,让你构造一个字符串,包含所有的m个子串,问有多少种构造方法.如果答案不超过42,则按字典序输出所有可行解. 由于m很小,所以可以考虑状压. 首先对全部m个子串构造出AC自动机,每个节点有一个附加属性val[u]代表结点u包含的子串集合. 设dp[l][S][u]为长度为l,包含子串集合为S,当前在结点u时,接下来能构造出的合法字符串总数,则dp[l][S][u]=∑dp[l+1][S|val[v]][v],v=go[u][i],0<=i<26; 两遍dfs,一遍dp,一遍输出答…