
图论
文章平均质量分 77
pizzaaaaa
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ 3498 March of the Penguins
很基础的网络流问题 题目里面有很明显的提示,每个冰块有它原来的在它上面的企鹅数量,也有跳出企鹅的数量。很显然我们建图的时候就可以把原来的企鹅数量作为入边,跳出的作为出边,为了限制出边,可以考虑拆点。把i拆成i与i+n,边的容量是m,而i+n与从i可跳到的冰块连边,为了方便起见,这条边的容量可以赋成inf。 #include "cstdio" #include "vector" #include原创 2014-02-22 17:25:35 · 529 阅读 · 0 评论 -
HDU 4780 Candy Factory
#include "cstdio" #include "cstring" const int N = 1111;//点 const int M = 111111;//边 const int inf = 1000000000; int min(int a,int b){return a<b ? a:b;} int max(int a,int b){return a>b ? a:b;} struct原创 2014-05-26 17:25:22 · 475 阅读 · 0 评论 -
POJ 2135 Farm Tour
#include "cstdio" #include "cstring" const int N = 1111;//点 const int M = 111111;//边 const int inf = 1000000000; int min(int a,int b){return a<b ? a:b;} struct Node{//边,点f到点t,流量为c,费用为w int f, t, c, w原创 2014-05-26 17:24:04 · 347 阅读 · 0 评论 -
POJ 1149 PIGS
#include "cstdio" #include "vector" #include "queue" #include "cstring" using namespace std; struct edge{int to,cap,rev;}; #define max_v 222 #define inf 11111111 vector g[max_v]; int level[max_v]; in原创 2014-05-26 17:22:30 · 362 阅读 · 0 评论 -
HDU 4322 Candy
#include "cstdio" #include "cstring" const int N = 111;//点 const int M = 1111;//边 const int inf = 1000000000; int min(int a,int b){return a<b ? a:b;} struct Node{//边,点f到点t,流量为c,费用为w int f, t, c, w; }原创 2014-05-26 17:21:18 · 489 阅读 · 0 评论 -
POJ 2112 Optimal Milking
这题稍微有一点难度,还是可做的。 题目的关键就是最小化最大值,这种题目一般情况下是二分答案进行判定。这题也不例外。 并且这道题目的点数比较少,所以可以重复建边。每次判定答案的时候都需要重新建图(这题的图比较好建),也就是只连长度比你判定的值小的边,然后跑一遍网络流就能过了。 也试过不是二分直接枚举,不幸TLE。。。简直不能更逗。 #include "cstdio" #include "ve原创 2014-02-22 22:19:48 · 506 阅读 · 0 评论 -
POJ 1273 Drainage Ditches
裸最大流,可以用来试一试模板的速度啥的。 #include "cstdio" #include "vector" #include "queue" #include "cstring" using namespace std; struct edge{int to,cap,rev;}; #define max_v 222 #define inf 11111111 vector g[max_v]原创 2014-02-22 22:13:50 · 407 阅读 · 0 评论 -
POJ 3281 Dining
比较基础的网络流。 如果只有食品或者只有饮料的话,直接二分图匹配就好了。 又有食品又有饮料,只要把一头牛拆成两头牛就好了,建图看我的程序就行了。 #include "cstdio" #include "vector" #include "queue" #include "cstring" using namespace std; struct edge{int to,cap,rev;}; #原创 2014-02-22 17:41:24 · 401 阅读 · 0 评论 -
HDU 3046 Pleasant sheep and big big wolf
网络流最大流最小割。 题目的意思就是说如何建立最小的栅栏,使得狼和羊之间没有一条路,狼和羊都在格子内。可以这么考虑,每个格子和它周围的四个格子(如果有的话)连边,而每条边就代表着一个栅栏,我们就是想要选择最小的栅栏,使得狼与羊之间没有路,也就是没有流量。将点分成三类构图,狼,羊,一般点。从s到狼连边,容量为inf,表明最小割不会割这条边,同理,从羊到t连边,容量为inf。而每条格子之间的边,容量原创 2014-02-22 17:48:27 · 532 阅读 · 0 评论 -
HDU 2768 Cat vs. Dog
一道需要考虑一下的匹配问题吧。 一开始自己看到这道题目,是想弄成二分图的形式,一边是猫,另一边是狗,但是这样建立每一组的关系有点复杂,并且不能套到二分图最大匹配的模型上。 后来再想了想,自己的方向有问题,应该是把人当作点,并根据人和人这件有没有矛盾关系来选择连不连边,这样这道题目就转化成了最大独立集的问题。 然后你跑一遍网络流,或者二分图匹配这题目就结束了。最大独立集=点数-最大匹配 #i原创 2014-02-22 22:11:37 · 553 阅读 · 0 评论 -
HDU 4411 Arrest
#include "cstdio" #include "cstring" const int N = 333;//点 const int M = 33333;//边 const int inf = 10000000; int min(int a,int b){return a<b ? a:b;} struct Node{//边,点f到点t,流量为c,费用为w int f, t, c, w; }e原创 2014-05-26 17:26:30 · 375 阅读 · 0 评论