AC Challenge(状压dp)】的更多相关文章

题目链接:https://nanti.jisuanke.com/t/30994 样例输入: 5 5 6 0 4 5 1 1 3 4 1 2 2 3 1 3 1 2 1 4 样例输出: 55 样例输入: 1 -100 0 0 样例输出: 0 题解: 把n道题目做了或者没做作为状态,裸的状压DP. 其中当前的时间 t,就是当前做了的题目数量加上1. AC代码: #include<bits/stdc++.h> using namespace std; typedef long long ll; co…
题目链接: https://nanti.jisuanke.com/t/30994 Dlsj is competing in a contest with n (0 < n \le 20)n(0<n≤20) problems. And he knows the answer of all of these problems. However, he can submit ii-th problem if and only if he has submitted (and passed, of c…
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…
题目链接 BZOJ1559 题解 考虑到这是一个包含子串的问题,而且子串非常少,我们考虑\(AC\)自动机上的状压\(dp\) 设\(f[i][j][s]\)表示长度为\(i\)的串,匹配到了\(AC\)自动机\(j\)号节点,且已匹配集合为\(s\)的方案数 直接在\(AC\)自动机上转移即可 但是为了防止使用\(last\)指针之类的,计算匹配的串,我们先将原串的集合去重和去包含关系 方案怎么办? 考虑到\(ans \le 42\),一定是刚好若干个原串以最长前后缀相同的方式相接 因为如果不…
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…
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…
题意:目标串n( <= 10)个,病毒串m( < 1000)个,问包含所有目标串无病毒串的最小长度 思路:貌似是个简单的状压DP + AC自动机,但是发现dp[1 << n][5e4]根本开不出那么多空间,似乎GG.但是我们仔细想一下就能发现,既然要包含所有目标串的最小长度,那必然这个串就是只有目标串叠加组成的,只是在叠加的过程中我们不能混入病毒串.所以其实Trie树上有用的点最多就10个,我们只要处理出所有目标串之间"最小有效转化"就行了,那么空间为dp[1…
题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has n 01 strings si, and he wants to know the number of 01 antisymmetric stri…
给你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,一遍输出答…