摘要: 题目传送门 1 /* 2 最短路: 不仅扫描边,还要扫描点;点有两种情况,一种刚好在中点,即从u,v都一样,那么最后/2 3 还有一种是从u,v不一样,两种的距离都是l 4 模板错了,逗了好久:( 5 */ 6 #include 7 #include... 阅读全文
posted @ 2015-07-19 21:37 Running_Time 阅读(211) 评论(0) 推荐(0)
摘要: 题目传送门 1 /* 2 贪心:当m == 2时,结果肯定是ABABAB或BABABA,取最小改变量;当m > 2时,当与前一个相等时, 改变一个字母 3 同时不和下一个相等就是最优的解法 4 */ 5 #include 6 #include 7 #include... 阅读全文
posted @ 2015-07-19 17:57 Running_Time 阅读(280) 评论(0) 推荐(0)
摘要: 题目传送门 1 /* 2 题意:求最少改变多少个0成1,使得每一个元素四周的和为偶数 3 状态压缩+枚举:枚举第一行的所有可能(1 7 #include 8 #include 9 using namespace std;10 11 const int MAXN = 20;12 con... 阅读全文
posted @ 2015-07-19 15:46 Running_Time 阅读(235) 评论(0) 推荐(0)
摘要: 题目传送门 1 /* 2 假设x1为1号给n号的金币数(逆时针),下面类似 3 a[1] - x1 + x2 = m(平均数) 得x2 = x1 + m - a[1] = x1 - c1; //规定c1 = a[1] - m,下面类似 4 a[2] - x2 + x3 = ... 阅读全文
posted @ 2015-07-19 14:17 Running_Time 阅读(215) 评论(0) 推荐(0)
摘要: 题目传送门 1 /* 2 贪心:按照执行时间长的优先来排序 3 */ 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 using namespace std;11 12 const int ... 阅读全文
posted @ 2015-07-19 14:04 Running_Time 阅读(139) 评论(0) 推荐(0)
摘要: 二分专题int p=lower_bound(A,A+n,x)-A; //查询>=x的第一个下标int p=upper_bound(A,A+n,x)-A; //查询>x的第一个下标int p=upper_bound(A,A+n,x)-A-1; //查... 阅读全文
posted @ 2015-07-19 13:28 Running_Time 阅读(198) 评论(0) 推荐(0)
摘要: 题目传送门 1 /* 2 二分图判定+点染色:因为有很多联通块,要对所有点二分图匹配,若不能,存在点是无法分配的,no 3 每一次二分图匹配时,将点多的集合加大最后第一个集合去 4 注意:n 7 #include 8 #include 9 #includ... 阅读全文
posted @ 2015-07-19 13:27 Running_Time 阅读(283) 评论(0) 推荐(0)
摘要: 题目传送门 1 /* 2 数学:这题一直WA在13组上,看了数据才知道是计算cost时超long long了 3 另外不足一个区间的直接计算个数就可以了 4 */ 5 #include 6 #include 7 #include 8 #include 9 #incl... 阅读全文
posted @ 2015-07-19 13:09 Running_Time 阅读(229) 评论(0) 推荐(0)