![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论-网络流
文章平均质量分 83
___Evan
这个作者很懒,什么都没留下…
展开
-
HDU-1533 KM Going Home 最佳匹配 最小费用最大流
/* 题目大意: 给你一个N行M列的矩阵,其中“.”代表空地,“H”代表房子,“m”代表人,其中有n个房子和n个人。现在要求每个人进入一间房子,且人走一步需要支付1美元。 求最小需要花费多少美元才能让所有人都进入到房子中(每个人只能进入一间房子,每个房子只能容纳一个人)。 解题思路: 这道题其实就是二分图最优匹配的变形而已。 因为要求的其实是最小权值之和。而KM算法求的是最大权值之和。 为此,我原创 2013-11-03 14:04:08 · 712 阅读 · 0 评论 -
FAFU-1198 小三大作战 小三大作战
http://acm.fafu.edu.cn/problem.php?id=1198 小三大作战 Time Limit: 2000MS Memory Limit: 65536KB原创 2013-11-25 10:34:49 · 619 阅读 · 0 评论 -
HDU-1565 方格取数(1) 网络流
http://acm.hdu.edu.cn/showproblem.php?pid=1565 题意: 给你一个n*n的格子的棋盘,每个格子里面有一个非负数。 从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的和最大。 算法分析: 最大独立点集 = 总点数 - 最小点覆盖集 独立集: 独立集是指图的顶点集的一个子集,该原创 2013-11-23 22:50:27 · 1244 阅读 · 0 评论 -
HDU-4292 Food 三分图
#include "stdio.h" #include "queue" #include "algorithm" using namespace std; const int maxn = 810; const int inf = 1<<30; int n,m,pos; struct Node { int v,w,next; Node() {}; Node( int v,int w,int原创 2013-11-27 23:02:02 · 557 阅读 · 0 评论 -
poj-1273 Drainage Ditches 最大流
/* http://poj.org/problem?id=1273 裸最大流 */ //EK算法 #include "stdio.h" #include "queue" using namespace std; const int maxn = 205; int map[maxn][maxn],path[maxn]; //邻接数组 前驱数组 int n,m; bool E原创 2013-11-03 14:11:21 · 801 阅读 · 0 评论 -
POJ-3469 Dual Core CPU 网络流
题意:一台双核电脑,给你多个任务,分别给出每个任务在第一个核和第二个核上运行的消耗。后面的m行输入是给出两个任务在两个不同核上运行需要付出的额外消耗。 建图:把每个任务作为节点,在超级源点与任务间的连一条边,其容量为给任务在核1上运行的消耗,在该任务节点与超级汇点之间连一条边,容量为该任务在核2上运行的消耗。 在任务之间连接无向边,容量为两个任务不在同一核上运行的原创 2013-11-27 18:08:01 · 577 阅读 · 0 评论 -
Ustc-1280 Finding shortest path 网络流
#include #include #include #include #include using namespace std; const int maxn = 2005; const int inf = 1<<30; int n,m,pos,Pos; int Start,End; struct node { int to,w,c,next; }edge[maxn*20]; stru原创 2014-04-14 21:50:08 · 423 阅读 · 0 评论 -
Hdu-4888 Redraw Beautiful Drawings 网络流
题目链接 #include "stdio.h" #include "queue" #include "iostream" #include "math.h" #include "algorithm" using namespace std; const int maxn = 1005; const int mod = 1000000007 ; const int inf = 1<<30;原创 2014-07-30 14:43:22 · 416 阅读 · 0 评论