题意:农场主想从1到n,然后从n到1,每条边最多走一次,不能走重复的路,问最短距离是多少。
建图:取超级源点s,并与房子连一条边,容量为2,费用为0;取barn与超级汇点 t 的边的容量为2,费用为0
房子与barn的费用为距离,容量为1
#include
#include
#include
#include
#include
#include
const int maxn =...
分类:
其他好文 时间:
2014-08-20 21:10:12
阅读次数:
365
题目链接:http://poj.org/problem?id=2195
题意:n*m的矩阵,地图上有若干个人(m)和房子(H),且人与房子的数量一致。man每移动一格费用为1,一个房子只能住一个人。现在要求所有的人出发,都入住房子,求最少话费。
思路:建立一个超级源点和汇点,源点与人相连费用为0,容量为1,人与房子相连,费用为人与房子的距离,容量为1,房子与汇点相连,费用为...
分类:
其他好文 时间:
2014-08-20 21:08:52
阅读次数:
305
#include #include #include #includeusing namespace std;const int N=300;const int MAXE=200000;const int inf=10&&d[u]+edge[j].w<d[v]) { ...
分类:
其他好文 时间:
2014-08-20 15:57:52
阅读次数:
231
题目链接:http://poj.org/problem?id=3281
努力练建图ing!!!
题意:有 N 头牛,有 F 种食物和 D 种饮料,每种食物或饮料只能供一头牛享用,且每头牛只享用一种食物和一种饮料。
第2行-第N+1行。是牛i 喜欢A种食物,B种饮料,及食物种类列表和饮料种类列表。
问最多能使几头牛同时享用到自己喜欢的食物和饮料。->最大流。
本题难...
分类:
其他好文 时间:
2014-08-19 20:54:25
阅读次数:
266
最大流 — Edmond Karp算法Edmond Karp算法的大概思想:反复寻找源点s到汇点t之间的增广路径,若有,找出增广路径上每一段[容量-流量]的最小值delta,若无,则结束。在寻找增广路径时,可以用BFS来找,并且更新残留网络的值(涉及到反向边)。而找到delta后,则使最大流值加上d...
分类:
其他好文 时间:
2014-08-19 16:11:45
阅读次数:
341
#include
#include
#include
#include
#include
#define N 1e9
using namespace std;
queueq;
int mapp[200][200];
int flow[200][200];
int a[200];
int p[200];
int n,m;
int min(int a,int b)
{
if(a>b)...
分类:
其他好文 时间:
2014-08-19 14:33:54
阅读次数:
194
#include #include #include #include #include #include #include #include #include #include #include using namespace std;const int INF=0x3f3f3f3f;int he...
分类:
其他好文 时间:
2014-08-19 12:36:45
阅读次数:
171
Romantic Value
Time Limit: 2 Seconds
Memory Limit: 65536 KB
Farmer John is a diligent man. He spent a lot of time building roads between his farms. From his point of view, every ro...
分类:
其他好文 时间:
2014-08-19 10:58:44
阅读次数:
228
??
Power NetworkCrawling in process...
Crawling failed
Time Limit:2000MS
Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit
Status
Description
A power network consist...
分类:
Web程序 时间:
2014-08-19 09:27:13
阅读次数:
442
题目链接:http://poj.org/problem?id=1149
题意:M个猪圈,N个顾客,每个顾客有一些的猪圈的钥匙,只能购买能打开的猪圈里的猪,而且要买一定数量的猪,每个猪圈有已知数量的猪,
但是猪圈可以重新打开,将猪的个数,重新分配,但是只能将猪往当前打开状态的猪圈里赶,以达到卖出的猪的数量最多。
思路:还是4部分,源点->猪圈->猪圈-...
分类:
其他好文 时间:
2014-08-18 22:06:42
阅读次数:
275