摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3784 【题解】 和超级钢琴很像啊。 一看题目,无脑点分。 那么我们发现点分的路径形式和“超级钢琴”的哪个很像啊。 点分是子树合并对吧,当前子树内的每个点都能选择前面子树的区间,那么跟“超级钢琴 阅读全文
posted @ 2017-05-01 20:09 Galaxies 阅读(324) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2006 【题解】 思路巧妙啊! 前置技能:序列和可以转化成前缀和的形式,那么前缀和左端点固定了右端点就是区间找最大值了。 记录五元组(from, l, r, pos, val)表示从from开始 阅读全文
posted @ 2017-05-01 20:05 Galaxies 阅读(445) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3687 【题解】 记f[i]为和为i的子集出现了几次。 那么加入一个数x,如果选择,就相当于f整体左移x;不选择就是f。那么异或起来就行了。 用bitset实现。复杂度O(n*2000000/3 阅读全文
posted @ 2017-05-01 19:49 Galaxies 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3992 【题解】 很容易得到一个dp但是复杂度不对 我们想到用原根把乘法改成加法。 然后a1a2...an=g^(b1+b2+...+bn) 我们找到g^k=x,那么就有b1+b2+...+bn 阅读全文
posted @ 2017-05-01 11:30 Galaxies 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4602 【题解】 对于每组齿轮(u, v)连边,权值为y/x(反向边x/y) 那么直接dfs计算一遍即可。 # include <math.h> # include <stdio.h> # in 阅读全文
posted @ 2017-05-01 09:49 Galaxies 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4006 【题解】 即求斯坦纳森林…… 然后我们发现可以先把所有点全当做重要点做一遍steiner tree。 然后我们可以求出联通状态为S的时候的最小花费 然后子集更新即可。(再一遍dp) 注意 阅读全文
posted @ 2017-04-30 22:38 Galaxies 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 传送门:(涉及版权忽略) 【题解】 我们发现n的范围很小,提示我们可以折半,然后我们就会了O(T2^(n/2)*n)的做法,然而会T。 考虑如何优化。直接排序会多一个log(2^(n/2))也就是n,那么改成每次加一个数,归并即可。这样复杂度是对的 T(n) = T(n-1) + 2^n ==> T 阅读全文
posted @ 2017-04-30 20:43 Galaxies 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4037 【题解】 我们发现容易得出递推式:f[i] = Σf[i-j] (1<=j<=m) 那么就能矩阵乘法了。容易构造转移矩阵: 如果是5*5的大概是这样: 0 1 0 0 0 0 0 1 0 阅读全文
posted @ 2017-04-30 20:13 Galaxies 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2595 【题解】 斯坦纳树模板题。学了一发斯坦纳树。 对于一般的斯坦纳树,是 给出一些点和一些关键点和边,要求选择权值和最小的连通块使得关键点连通。 那么一般我们用f(x,status)表示在x 阅读全文
posted @ 2017-04-29 21:54 Galaxies 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3098 【题解】 生日问题:如果在[1,n]中选数,那么平均根号n次就能选到重复的。 那么直接随机即可。 注意l不能太小也不能太大,取20左右即可。 # include <stdio.h> # 阅读全文
posted @ 2017-04-29 17:19 Galaxies 阅读(176) 评论(0) 推荐(0) 编辑