2013年7月29日

最小费用最大流——maxflow+SPFA

摘要: 最小费用最大流: 即在所有最大流中,要求得到最少费用。(每条边有两个参数:容量cap, 费用cost)。 解法:每次找到费用最小的增广路。(即以费用为权的最短路) 仅需将最大流中的 bfs 替换为SPFA(因为有负权)。代码如下: 1 #define MAXN 1005 2 #define MAXM 10005 3 #define INF 0x3f3f3f3f 4 using namespace std; 5 6 struct P{ 7 int u, v, cap, cost, next; //容量cap, 单位流量费用cost。 8 }e[MAXM*4];... 阅读全文

posted @ 2013-07-29 19:36 KimKyeYu 阅读(580) 评论(0) 推荐(0) 编辑

导航