http://codeforces.com/contest/787/problem/E 题目大意:给你n块,每个块都有一个颜色,定义一个k,表示在区间[l,r]中最多有k中不同的颜色.另k=1,2,3...n,问在每一种情况下,输出能划分出的最小的段落数. 例如: 51 3 4 3 3 ans = 4, 2, 1, 1, 1 [1], [3], [4], [3, 3] [1], [3, 4, 3, 3] [1, 3, 4, 3, 3] [1, 3, 4, 3, 3] [1, 3, 4, 3, 3…
题目传送门 /* 线段树的单点更新:有一个交叉更新,若rank=1,or:rank=0,xor 详细解释:http://www.xuebuyuan.com/1154895.html */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <cmath> #include <…
题目传送门 /* 题意:对于长度为x的子序列,每个序列存放为最小值,输出长度为x的子序列的最大值 set+线段树:线段树每个结点存放长度为rt的最大值,更新:先升序排序,逐个添加到set中 查找左右相邻的位置,更新长度为r - l - 1的最大值,感觉线段树结构体封装不错! 详细解释:http://blog.csdn.net/u010660276/article/details/46045777 其实还有其他解法,先掌握这种:) */ #include <cstdio> #include &l…
B. Legacy 题目连接: http://codeforces.com/contest/786/problem/B Description Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy to Morty before bad guys catch them. There are…
来自FallDream的博客,未经允许,请勿转载,谢谢. ------------------------------------------------------- 大家好,我是一个假人.在学习OI的过程中,我凭借自己的努力,成功发明出了大顶的dij,并且帮助自己在cf和模拟赛上多过了 -2 道题.发明算法真美妙! -------------------------------------------------------- 不说了,D题因为dij打成大顶的挂了,血都吐出来了.A题瞎特判f…
The Monster 签到题,算一下b+=a和d+=c,然后卡一下次数就可以了. Not Afraid 只要一组出现一对相反数就是安全的. Berzerk 题意:[1,n],两个人轮流走,谁能走到1谁就赢,求每个人先手在[2,n]时的胜负情况. 一直没怎么写过博弈论的题,但其实这种题也只是一个bfs. 必胜态:有一条边走到必败态 必败态:连出去的所有边都是必胜态. 方法:倒着bfs,把1作为必败态进队,如果当前是必败态,能到达都是必胜态,如果当前是必胜态,能到达的所有的点入度-1,如果入度减到…
B. Legacy 题目连接: http://codeforces.com/contest/786/problem/B Description Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy to Morty before bad guys catch them. There are…
D. Legacy time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy…
http://codeforces.com/contest/787/problem/D 题目大意:有n个点,三种有向边,这三种有向边一共加在一起有m个,然后起点是s,问,从s到所有点的最短路是多少? 第一种边:u->v w 表示节点u到v有连接一条有向边,权值为w 第二种边:u->[l,r] w  表示节点u到区间[l,r]连接一条有向边,权值为w 第三种边:[l,r]->u w  表示区间[l, r]所有的节点到u都有一条有向边,权值为w 思路: 我们知道,对于dijstra都是用pr…
D. Legacy time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy…