随笔分类 -  最小费用最大流

 
HDU 3376
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3376题意:一个矩阵,每个点有价值,起点左上角终点右下角,每次只能走当前点的下一点或右一点,从起点走到终点,再从终点回到起点,走的点不能重复,问能取到的最大价值用费用流做建图:拆点(保证每个点只取1次),除了起点和... 阅读全文
posted @ 2014-07-30 18:49 LegendaryAC 阅读(323) 评论(0) 推荐(0)
HDU 1853
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1853和下题一模一样,求一个图环的并,此题的题干说的非常之裸露http://www.cnblogs.com/xiaohongmao/p/3873957.html#include #include #include ... 阅读全文
posted @ 2014-07-28 21:37 LegendaryAC 阅读(205) 评论(0) 推荐(0)
HDU 3455
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3435同下题,只是这题是双向边,同时让我认识到了一个问题,一个图拆点做二分图完美匹配的本质是求该图环的并http://www.cnblogs.com/xiaohongmao/p/3873957.html#inclu... 阅读全文
posted @ 2014-07-28 21:30 LegendaryAC 阅读(170) 评论(0) 推荐(0)
HDU 4862
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4862#include #include #include #include #include using namespace std ;const int INF=0xfffffff ;struct node{ ... 阅读全文
posted @ 2014-07-28 21:04 LegendaryAC 阅读(179) 评论(0) 推荐(0)
HDU 3488
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3488原来写过的一道题,今天重新看费用流又做了一遍题意:给一个图,求环的并(权值和最小)思路:每个点只能走一次,且都要走,所以一个点的出度入度均为1,因此拆点建图跑二分图最优匹配用费用流写的,速度比km慢#incl... 阅读全文
posted @ 2014-07-28 20:46 LegendaryAC 阅读(430) 评论(0) 推荐(0)
HDU 3667
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3667最小费用最大流本题流量和费用不是线性关系,fee=a*flow*flow,所以常规套模板spfa无法得到最小费用观察到每条边流量上限只有5,则可以把一条流量为f的边拆成f条流量为1的边,每条边费用是a*(2*... 阅读全文
posted @ 2014-05-07 21:15 LegendaryAC 阅读(194) 评论(0) 推荐(0)
HDU 2485
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2485n个车站,m条边,两边之间费用为1,问最少摧毁多少车站,使得1-n无法在k时间内到达将2-(n-1)每个点拆成两个,并建立容量为1,费用为0的一条边,源点为1,汇点为2*n-2,这时求最小费用最大流,其中保证... 阅读全文
posted @ 2014-04-27 20:26 LegendaryAC 阅读(271) 评论(0) 推荐(0)
最小费用最大流
摘要:每边有一个权值,要求得到最大流并且使得权值和最小把EK算法中的bfs改成spfa,spfa需要注意的是进行松弛的边容量不能为0const int INF=0xfffffff ;struct node{ int s,t,cap,cost,nxt ;}e[200005] ;int sumflow ... 阅读全文
posted @ 2014-04-27 19:32 LegendaryAC 阅读(130) 评论(0) 推荐(0)
HDU 1533
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1533人和房子数量相同,每个人进房子,费用是人到房子的曼哈顿距离,求最小费用可用最小费用最大流求解,建立虚拟的源点和汇点即可#include #include #include #include using nam... 阅读全文
posted @ 2014-04-26 21:37 LegendaryAC 阅读(128) 评论(0) 推荐(0)