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 course) s_isi​ problems, the p_{i, 1}pi,1​…
AC Challenge 30.04% 1000ms 128536K   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 cours…
ACM-ICPC 2018 南京赛区网络预赛E: 题目链接https://www.jisuanke.com/contest/1555?view=challenges 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…
https://nanti.jisuanke.com/t/30994 题意 给你n个题目,对于每个题目,在做这个题目之前,规定了必须先做哪几个题目,第t个做的题目i得分是t×ai+bi问最终的最大得分是多少? 分析 枚举所有状态,在转移时判断合法性,然后直接转移就好了.dp初始化为-inf,边界值dp[0]=0; #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring&g…
看到20的数据量很容易想到状压dp. 开1<<20大小的数组来记录状态,枚举n个糖包,将其放入不同状态中(类似01背包思想) 时间复杂度O(n*(2^20)). import java.util.Arrays; import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); static int[][] a = new int[105][25]; static int[] sta…
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…
题意:给出一个4×4的点阵,连接相邻点可以构成一个九宫格,每个小格边长为1.从没有边的点阵开始,两人轮流向点阵中加边,如果加入的边构成了新的边长为1的小正方形,则加边的人得分.构成几个得几分,最终完成九宫格时,谁的分高谁赢.现在给出两人前若干步的操作,问接下来两人都采取最优策略的情况下,谁赢. 分析:博弈搜索,有人说要加记忆化,我没有加也过了……与赤裸裸的博弈搜索的区别在于对于最终状态,并不是谁无路可走谁输,而是谁分低谁输.注意判断分数相等的情况.在搜索中每个节点要么是必胜态,要么是必败态,可参…
\(\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…
[noip模拟赛5]细菌   描述 近期,农场出现了D(1<=D<=15)种细菌.John要从他的 N(1<=N<=1,000)头奶牛中尽可能多地选些产奶.但是如果选中的奶牛携带了超过 K (1<=K<=D)种不同细菌,所生产的奶就不合格.请你帮助John 计算出最多可以选择多少头奶牛. 输入 第一行:三个整数N,D,K 下面N行:第i行表示一头牛所携带的细菌情况.第一个整数di表示这头牛所携带的细菌种类数,后面di个整数表示这些细菌的各自种类标号. 输出 只一个数 M…
题意:给定 n 个文本串,m个病毒串,文本串重叠部分可以合并,但合并后不能含有病毒串,问所有文本串合并后最短多长. 析:先把所有的文本串和病毒都插入到AC自动机上,不过标记不一样,可以给病毒标记-1,如果访问知道就知道不可行的,然后处理出两两串叠加的最小长度,这个要用bfs,在AC自动机上把这个处理出来,然后剩下的就是一个简单的DP了,dp[s][i] 表示状态为 s 时,i 串在后面,长度最短是多少. 代码如下: #pragma comment(linker, "/STACK:10240000…