![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
----------网络流
mfcheer
他不停地跑啊跑 就为了追上那个曾经被寄予厚望的自己
展开
-
最大流SAP -邻接表模板
const int MAXN = 1010;//点数的最大值const int MAXM = 400010;//边数的最大值const int INF = 0x3f3f3f3f;struct Edge{ int to, next, cap, flow;}edge[MAXM];//注意是MAXMint tol;int head[MAXN];int gap[MAXN], dep[原创 2015-06-05 23:27:45 · 678 阅读 · 0 评论 -
SGU 194. Reactor Cooling【无源汇上下界最大流】
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=194当所有附加边全部满流时(即maxflow==所有du[]>0之和),有可行解。代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #i原创 2015-09-04 23:42:29 · 558 阅读 · 0 评论 -
poj 2195 Going Home【zkw费用流】
题目链接:http://poj.org/problem?id=2195题意:每个人都走到一个屋子的最小花费。二分图类型代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #include <sstream>原创 2015-09-05 12:37:53 · 353 阅读 · 0 评论 -
hdu 3667 Transportation【费用流 + 拆边】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3667解法:大白书366页,拆边法SPFA代码(AC):#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #incl原创 2015-09-05 03:12:47 · 355 阅读 · 0 评论 -
zkw费用流模板
模板: 对二分图类型效率高// hdu 3667#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #include <sstream> #include <stdio.h> #include <mat原创 2015-09-05 03:15:24 · 415 阅读 · 0 评论 -
hdu 4289 Control【最小割+拆点】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4289代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #include <sstream> #inclu原创 2015-09-05 18:15:40 · 316 阅读 · 0 评论 -
hdu 4280 Island Transport 【网络流+优化】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4280题意:给你点坐标,由右下角向左上角走的最大流。卡时间代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #原创 2015-09-07 00:26:44 · 342 阅读 · 0 评论 -
LA 3231 Fair Share 【二分+最大流】
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1232题意:最小化网络流边中最大流量的最大值。二分流量求值代码:#include <iostream> #include <algorithm> #include <set>原创 2015-09-07 20:14:16 · 585 阅读 · 0 评论 -
hdu 3879 Base Station【最大权闭合图】
最大权闭合图学习资料:http://www.cnblogs.com/wuyiqi/archive/2012/03/12/2391960.html最大权 = 正的权值的和-建图后的最小割的容量。题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3879题意:有n个点,m个选择,建造n个点各自需要一定花费,每个选择有一定的获利,会选择两个点。求最大的获利代码:原创 2015-09-08 01:49:42 · 405 阅读 · 0 评论 -
BZOJ [BeiJing2006]狼抓兔子 【网络流】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1001就是求最小割 阻止两个兔子窝间联通代码:#include <iostream>#include <algorithm>#include <set>#include <map>#include <string.h>#include <queue>#include <sstrea原创 2015-10-07 23:46:34 · 380 阅读 · 0 评论 -
hdu 1565 方格取数(1)【最大流】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1565代码:#include <iostream>#include <algorithm>#include <set>#include <map>#include <string.h>#include <queue>#include <sstream>#include <stdio.h>#原创 2015-10-10 19:53:46 · 379 阅读 · 0 评论 -
hdu 2686 Matrix【费用流】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686代码:#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#i原创 2015-10-13 15:13:32 · 418 阅读 · 0 评论 -
poj 2987 Firing【最大闭合子图】
题目链接:http://poj.org/problem?id=2987最闭合子图资料:http://blog.sina.com.cn/s/blog_48f85e1d0100mxem.html代码:#include <iostream>#include <algorithm>#include <set>#include <map>#include <string.h>#include <qu原创 2015-10-13 20:27:18 · 369 阅读 · 0 评论 -
poj 2289 Jamie's Contact Groups【二分 + 最大流】
题目:http://poj.org/problem?id=2289二分分组容量。 建图:源点向人,容量1,分组向汇点,容量为二分值。人向分组,容量为1。代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #原创 2015-09-09 22:11:32 · 166 阅读 · 0 评论 -
LightOJ 1177 - Angry Programmer【最大流最小割】
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1177题意为求最小割。由最小割最大流定理 :最小割 ==》最大流代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #incl原创 2015-09-02 19:33:48 · 443 阅读 · 0 评论 -
POJ 1273 DRAINAGE DITCHES【最大流】
模板题。 DescriptionEvery time it rains on Farmer John’s fields, a pond forms over Bessie’s favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to原创 2015-06-05 23:28:21 · 430 阅读 · 0 评论 -
最大流SAP模板(邻接矩阵)
#include <stdio.h>#include <math.h>#include <stdlib.h> #include <ctype.h> #include <algorithm> #include <vector> #include <string.h> #include <queue> #include <stack> #include <set> #原创 2015-06-05 23:28:45 · 600 阅读 · 0 评论 -
poj 2195 Going Home【最小费用最大流】
题目链接: http://poj.org/problem?id=2195题意:给你一些人的位置,和屋子的位置,求使得所有人回到屋子的最小花费是多少。每个屋子只能装一人。人每横着或竖着走一步,花费为1。解法:最小费用流。bin神板子 建图是原点到人 ,人到屋子, 屋子到汇点。流量均为1,人与屋子费用为距离。其他费用为0;代码:/*POJ 2195 Going Home邻接矩阵形式最小费用最大流原创 2015-08-07 20:19:15 · 588 阅读 · 0 评论 -
poj 1087 A Plug for UNIX 【最大流】
题目连接:http://poj.org/problem?id=1087题意: n种插座 ,m个电器,f组(x,y)表示插座x可以替换插座y,问你最多能给几个电器充电。解法:起点向插座建边,容量1,电器向汇点建边,容量1,插座向电器建边,容量1,可以替换的插座间建边,容量无穷大。然后套板子。。。求最大流。代码:#include <stdio.h> #include <ctime> #incl原创 2015-08-08 00:35:43 · 863 阅读 · 0 评论 -
poj 2526 Minimum Cost【最小费用最大流】
题目链接:http://poj.org/problem?id=2516题意: n个店主 m个供应商 k种货物 给你店主对k种货物的需求及供货商k种货物的囤货量及K种运输费用。解法:k次费用流,分别求每种货物的费用。源点到供应点建边,店主到汇点建边,费用均为0,容量为1。然后供应点到店主建边,费用为矩阵,容量无穷大即可。代码:/*POJ 2195 Going Home邻接矩阵形式最小费用最大流原创 2015-08-08 13:38:11 · 673 阅读 · 0 评论 -
poj 3281 Dining 【最大流】
题目链接:http://poj.org/problem?id=3281题意: 给出牛n,饮料d还有食物f的数量,每头牛给出喜欢的饮料和食物,最后求出能够满足的牛的数量解法:源点到食物建边, 由食物到牛建边, 牛到饮料建边 ,饮料到汇点建边 ,求最大流。牛要拆点控制流量为1全部是有向的边,而且权值全部为1 有2*n+f+d+2个顶点 0表示源点,2*n+f+d+1表示汇点 1到f为食物点,f+原创 2015-08-07 16:04:13 · 554 阅读 · 0 评论 -
UVA 10746 Crime Wave - The Sequel【最小费用最大流】
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1687题意:给你n个城市到m个海港的距离,求每个城市都有船只去的最短平均航行距离。源点向城市建边 城市向海港 海港向汇点建边 容量为1,最后城市向海港的费用为距离代码:#include<stdi原创 2015-08-16 13:32:45 · 631 阅读 · 0 评论 -
LightOJ 1153 - Internet Bandwidth【最大流】
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1153注意自环代码:原创 2015-08-31 20:25:28 · 498 阅读 · 0 评论 -
LightOJ 1155 - Power Transmission【拆点网络流】
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=11551~N每个点有容量限制,这样就把每个点拆开,容量为限制的容量。代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #in原创 2015-09-01 22:18:20 · 407 阅读 · 0 评论 -
LightOJ 1176 - Getting a T-shirt【最大流】
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1176建图:源点向人,人向6*n个衣服,衣服向汇点,容量均为1。代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #incl原创 2015-09-02 00:03:30 · 371 阅读 · 0 评论 -
POJ 2112 Optimal Milking【二分+最大流】
题目链接:http://poj.org/problem?id=2112最小化最大流量边。 建图:源点向机器建边,容量为m,牛向汇点建边,容量1,机器与牛之间建边(若符合条件),容量1。代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #inc原创 2015-09-09 21:22:14 · 368 阅读 · 0 评论 -
hdu 4292 Food【拆点网络流】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4292解法:拆人代码:#include <stdio.h> #include <ctime> #include <math.h> #include <limits.h> #include <complex> #include <string> #include <functiona原创 2015-08-19 03:33:28 · 648 阅读 · 0 评论 -
hdu 5889 Barricade【最小割】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5889解法:求最短路图上的最小割,先在图上源点和终点分别求一遍最短路。再在最短路图上求最小割。 最小割==最大流定理代码:#include <stdio.h>#include <math.h>#include <algorithm>#include <iostream>#include <str原创 2016-09-18 09:49:06 · 524 阅读 · 0 评论