USACO: Pollutant Control

本文介绍了一个基于最大流最小割原理的算法问题,旨在通过关闭特定的配送路线来阻止受污染牛奶到达零售商。需要找到成本最低且数量最少的关闭路线组合。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Pollutant Control
Hal Burch

It's your first day in Quality Control at Merry Milk Makers, and already there's been a catastrophe: a shipment of bad milk has been sent out. Unfortunately, you didn't discover this until the milk was already into your delivery system on its way to stores. You know which grocer that milk was destined for, but there may be multiple ways for the milk to get to that store.

The delivery system is made up of a several warehouses, with trucks running from warehouse to warehouse moving milk. While the milk will be found quickly, it is important that it does not make it to the grocer, so you must shut down enough trucks to ensure that it is impossible for the milk to get to the grocer in question. Every route costs a certain amount to shut down. Find the minimum amount that must be spent to ensure the milk does not reach its destination, along with a set of trucks to shut down that achieves this goal at that cost.

PROGRAM NAME: milk6

INPUT FORMAT

Line 1: Two space separated integers, N and M. N (2 <= N <= 32) is the number of warehouses that Merry Milk Makers has, and M (0 <= M <= 1000) is the number of trucks routes run. Warehouse 1 is actually the productional facility, while warehouse N is the grocer to which which the bad milk was destined.
Line 2..M+1: Truck routes: three space-separated integers, Si, Ei, and Ci. Si and Ei (1 <= Si,Ei <= N) correspond to the pickup warehouse and dropoff warehouse for the truck route. Ci (0 <= Ci <= 2,000,000) is the cost of shutting down the truck route.

SAMPLE INPUT (file milk6.in)

4 5
1 3 100
3 2 50
2 4 60
1 2 40
2 3 80

OUTPUT FORMAT

The first line of the output should be two integers, C and T. C is the minimum amount which must be spent in order to ensure the our milk never reaches its destination. T is the minimum number of truck routes that you plan to shut down in order to achive this goal. The next T lines sould contain a sorted list of the indexes of the truck routes that you suggest shutting down. If there are multiple sets of truck routes that achieve the goal at minimum cost, choose one that shuts down the minimum number of routes. If there are still multiple sets, choose the one whose initial routes have the smallest index.

SAMPLE OUTPUT (file milk6.out)

60 1
3


思路:

这题是看了题解才过的,so不敢献丑放代码了,只大略讲一下思路。

这个问题应用最大流最小割定理,把每辆卡车的停运费用作为管道的流量,那么从污染源到目的地的这个流网络的最大流就是最小的停运费用。也就是因为一开始这个模型转换很费解,所以我一直转不过弯来。可以这样理解吧,因为不确定是哪辆车载了受污染的牛奶,所以不得不截断所有可能造成污染的路径,这也就形成了一个类似瓶颈问题的策略,要使最大的流量的截止代价最小。orz,越说越乱……

然后是构造解,要删去的边标记一下即可,只是问题存在两个权值:对于卡车流通来说,只需要用1和0来表示连通性,而对于停运费用来说则是不同的,所以看到多数题解上都是使用“乘上一个大数然后+1”之类的权值算法,这真是一种又聪明又令人纠结的方法啊……

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值