上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 15 下一页
摘要: Description "题目链接" Solution 用三进制表示陷阱状态,1表示有害,2表示无害,0表示不知道 用$f[S][i]$表示状态为S时陷阱i有害的概率,这个可以预处理出 $d[S][i][j][h]$表示状态为S,在坐标$(i,j)$,血量为h时的答案 然后就可以DP了,记忆化搜索 阅读全文
posted @ 2018-04-04 10:22 void_f 阅读(230) 评论(0) 推荐(0) 编辑
摘要: Description "题目链接" Solution 容斥原理,答案为忽略质数限制的方案数减去不含质数的方案数 然后矩阵乘法优化一下DP即可 Code c++ include include include define N 120 using namespace std; const int M 阅读全文
posted @ 2018-04-03 14:57 void_f 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Description 一个可重复数字集合S的神秘数定义为最小的不能被S的子集的和表示的正整数。 例如S={1,1,1,4,13}, 1 = 1 2 = 1+1 3 = 1+1+1 4 = 4 5 = 4+1 6 = 4+1+1 7 = 4+1+1+1 8无法表示为集合S的子集的和,故集合S的神秘数 阅读全文
posted @ 2018-03-30 21:21 void_f 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Description "题目链接" Solution 在虚树上跑DP即可 关于虚树的建立,是维护一个最右链的过程 关键代码如下: c++ sort(A+1,A+k+1,cmp);//按dfs序排序 s[top=1]=1;//栈维护最右链 for(int i=1;i1&&dep[f] include 阅读全文
posted @ 2018-03-30 19:12 void_f 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Description "题目链接" Solution 在虚树上跑DP即可 Code c++ include include include include define ll long long define N 250010 using namespace std; const ll Inf=1 阅读全文
posted @ 2018-03-30 19:08 void_f 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Description "题目链接" Solution 可以想到,每次肯定是拿最大价值为最优 考虑改变树上一个点的值,只会影响它的子树,也就是dfs序上的一个区间, 于是可以以dfs序建线段树,这样就变成区间问题了 Code c++ include include define MID int mi 阅读全文
posted @ 2018-03-30 15:15 void_f 阅读(215) 评论(0) 推荐(0) 编辑
摘要: Description "题目链接" Solution 用set按dfs序维护当前的宝物序列,那么答案为相邻2个点的距离加上头尾2个的距离 Code 阅读全文
posted @ 2018-03-28 19:37 void_f 阅读(214) 评论(0) 推荐(0) 编辑
摘要: Description "题目链接" Solution 设S[i]表示到第i天总共S[i]几个标记, 那么满足S[i]=m[i]+d[i]+1 m[i]表示水位上的标记数,d[i]表示水位下的标记数 那么可以发现,S[i]满足非严格递增,且相邻2个相差不超过1 由此可转化题目, 给你n个数,可以给任 阅读全文
posted @ 2018-03-26 19:56 void_f 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Description 某个国家有n个城市,这n个城市中任意两个都连通且有唯一一条路径,每条连通两个城市的道路的长度为zi(zi include include include include define N 300010 define ll long long using namespace s 阅读全文
posted @ 2018-03-24 15:13 void_f 阅读(140) 评论(0) 推荐(0) 编辑
摘要: Description "题目链接" Solution 从起点和终点分别做一次最短路并记录结果 枚举每一条可能的边判断 Code 阅读全文
posted @ 2018-03-23 14:30 void_f 阅读(535) 评论(1) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 15 下一页