摘要: 题意:给定n个点,m条边,以及起点s,终点t,问你图中是否存在s->t的最短路为L,其中权值为0的可以任意修改。 思路:对给定的边分为2类,权重不为0的直接扔进去建图,权重为0的边先存起来。接着跑一遍堆优化的dij,如果dis[t]小于L,那么无论怎么修改权重0的边都没有办法凑出最短路L; 如果di 阅读全文
posted @ 2017-01-12 23:05 Kcl886 阅读(288) 评论(0) 推荐(0)
摘要: 思路:看了很久才知道题意,虽然51nod分类为博弈,但我感觉还是不像。解法已经隐藏在样例中了,无论正还是反,最后的期望都是一样的。设美女正面的概率为p,反面为(1-p)则 p*A-(1-p)*(A+B)/2 = (1-p)*B-p*(A+B)/2,解得:P=(A+3*B)/(4A+4B),最后取下g 阅读全文
posted @ 2017-01-10 01:11 Kcl886 阅读(197) 评论(0) 推荐(0)
摘要: 思路:集合Y中两类数存在是不可能合成X的,一类是比X大的数,一类是X的二进制表示中某些位为0,而这些数对应的二进制表示的位的数字是1。先把这两类数字排除掉, 再对处理后的集合Y中的所有数字进行分位统计,最后那个X的二进制表示中为1的位中数字最小的就是答案了。 1 #include <iostream 阅读全文
posted @ 2017-01-10 00:57 Kcl886 阅读(413) 评论(0) 推荐(0)
摘要: 思路:先把最左和最右的干掉,剩下的再一起dfs。dfs的时候注意当第cur-1个死了之后(而第cur个不要求必须死)才向后面搜索第cur+1个。 当前的第cur个可以被扔在自己身上的火球,也可被扔在第cur+1个的火球干掉。 1 #include <iostream> 2 #include <que 阅读全文
posted @ 2017-01-09 17:57 Kcl886 阅读(155) 评论(0) 推荐(0)
摘要: 思路:依次把x【】数组的元素加入set,再二分出当前入set元素在set中的上界r和下界l,则这段区间能放的最多的战舰数量就由原来的(r-l)/(a+1)减少为(x[i]-l)/(a+1)+(r-x[i])/(a+1), 每次判断加入新元素后能放最多战舰数sum与k的大小即可。 1 #include 阅读全文
posted @ 2017-01-09 13:27 Kcl886 阅读(194) 评论(0) 推荐(0)
摘要: 思路:当初做的时候YY了好久一直YY不出来,查了题解发现好多种解法,学了一种最简单的,确实是一道不错的题,以下截图自其它大牛博客。 1 #include <iostream> 2 #include <queue> 3 #include <stack> 4 #include <cstdio> 5 #i 阅读全文
posted @ 2017-01-09 13:01 Kcl886 阅读(237) 评论(0) 推荐(0)
摘要: 思路:想了好久都想不到怎么居然是直接模仿二进制进位,最后数下有多少个1即可,真是神奇! 1 #include <iostream> 2 #include <queue> 3 #include <stack> 4 #include <cstdio> 5 #include <vector> 6 #inc 阅读全文
posted @ 2017-01-09 12:50 Kcl886 阅读(238) 评论(0) 推荐(0)
摘要: 1 #include <iostream> 2 #include <queue> 3 #include <stack> 4 #include <cstdio> 5 #include <vector> 6 #include <map> 7 #include <set> 8 #include <bits 阅读全文
posted @ 2017-01-09 11:20 Kcl886 阅读(126) 评论(0) 推荐(0)
摘要: D - Laying Cables Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u One-dimensional country has n cities, the i-th of which is loc 阅读全文
posted @ 2016-09-03 21:47 Kcl886 阅读(295) 评论(0) 推荐(0)
摘要: J - Sockets Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Valera has only one electrical socket in his flat. He also has m dev 阅读全文
posted @ 2016-09-03 15:28 Kcl886 阅读(291) 评论(0) 推荐(0)