数学解释不多说了,参考:http://blog.youkuaiyun.com/scorpiocj/article/details/6085637
最大权闭合图,最大权=sum-最小割,sum为所有正点权的和;要裁掉几个人,根据最小割的性质,被裁掉的人肯定不在最小割中,所以只要从源点开始对残留网络进行遍历即可。
注意一点,sum类型为long long,否则出错。
/*
* Dinic algo for max flow
*
* This implementation assumes that #nodes, #edges, and capacity on each edge <= INT_MAX,
* which means INT_MAX is the best approximation of INF on edge capacity.
* The total amount of max flow computed can be up to LLONG_MAX (not defined in this file),
* but each 'dfs' call in 'dinic' can return <= INT_MAX flow value.
*/
#include <stdio.h>
#include <stdlib.h>

本文介绍了如何利用最大权闭合图解决poj2987题目的Firing问题。最大权等于所有正点权重之和减去最小割。在确定裁员方案时,根据最小割的特性,被裁掉的员工不在最小割路径上。通过从源点遍历残留网络可以找到解决方案。注意处理sum时需使用long long类型避免溢出。
最低0.47元/天 解锁文章
139

被折叠的 条评论
为什么被折叠?



