Codeforces - 1194D - 1-2-K Game - dp】的更多相关文章

https://codeforc.es/contest/1194/problem/D 打个n=30的表好像看出了规律. 其实假设k==3,那么 sg[0]=0, sg[1]=mex{sg[0]}=1, sg[2]=mex{sg[0],sg[1]}=2, sg[3]=mex{sg[0],sg[1],sg[2]}=3, sg[4]=mex{sg[1],sg[2],sg[3]}=0, sg[5]=mex{sg[2],sg[3],sg[4]}=1, sg[6]=mex{sg[3],sg[4],sg[5]…
题目链接: http://codeforces.com/contest/161/problem/D D. Distance in Tree time limit per test 3 secondsmemory limit per test 512 megabytes 问题描述 A tree is a connected graph that doesn't contain any cycles. The distance between two vertices of a tree is th…
题目链接:http://codeforces.com/contest/682/problem/D 给你两个字符串,求两个字符串中顺序k个的相同子串 长度之和.(注意是子串) dp[i][j][k][0] 表示a[i] == a[j]时,a字符串前i个和b字符串前j个,顺序k个相同的子串 长度之和 dp[i][j][k][1] 表示a[i] != a[j]时,顺序k个相同子串的长度之和 dp[i][j][k][0] = max(dp[i - 1][j - 1][k][0], dp[i - 1][j…
题目链接:Codeforces 461B Appleman and Tree 题目大意:一棵树,以0节点为根节点,给定每一个节点的父亲节点,以及每一个点的颜色(0表示白色,1表示黑色),切断这棵树的k条边,使得树变成k+1个联通分量.保证每一个联通分量有且仅有1个黑色节点.问有多少种切割方法. 解题思路:树形dp,dp[i][0]和dp[i][1]分别表示子树一下的切割方法中,i节点所在联通块不存在黑节点和已经存在一个黑节点的方案数. #include <cstdio> #include &l…
http://codeforces.com/contest/588/problem/D 感觉吧,这道题让我做,我应该是不会做的... 题目大意:给出n,L,K.表示数组的长度为n,数组b的长度为L,定义数组b[i]=a[i%n].然后数组b的最长的lis为k,问能有几组<=k的lis 条件如下: ①序列长度>=1并且<=k ②序列在每一块长度为n的数组中只能选择一个数,且选择的必须是连续的块 ③序列是不严格的单调递增 思路:主要是看这个人的http://m.blog.csdn.net/a…
题目链接:http://codeforces.com/contest/598/problem/E E. Chocolate Bar time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a rectangular chocolate bar consisting of n × m single squares. Y…
Aragorn's Story Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/148/E Description Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who…
题目链接:http://codeforces.com/problemset/problem/509/F 题意: 告诉你遍历一棵树的方法,以及遍历节点的顺序a[i],长度为n. 问你这棵树有多少种可能的形态. 遍历方法: used[1 ... n] = {0, ..., 0}; procedure dfs(v): print v; used[v] = 1; for i = 1, 2, ..., n: if (a[v][i] == 1 and used[i] == 0): dfs(i); dfs(1…
题目链接:http://codeforces.com/contest/440/problem/D D. Berland Federalization   Recently, Berland faces federalization requests more and more often. The proponents propose to divide the country into separate states. Moreover, they demand that there is a…
http://codeforces.com/problemset/problem/730/J 题意:有n个瓶子,每个瓶子有一个当前里面的水量,还有一个瓶子容量,问要把所有的当前水量放到尽量少的瓶子里至少需要几个瓶子,还有最少需要倒的水量(把一个瓶子的水倒到另一个瓶子的总水量). 思路:是一个背包dp,dp[i][j] 表示选择i个瓶子容量为j的时候当前拥有的最大的水量.不过第三层循环当时不知道应该怎么写. #include <cstdio> #include <cstring> #…