Coding Contest HDU - 5988 (运用log转乘法为加法,费用流)

Coding Contest

 HDU - 5988 

A coding contest will be held in this university, in a huge playground. The whole playground would be divided into N blocks, and there would be M directed paths linking these blocks. The i-th path goes from the uiui-th block to the vivi-th block. Your task is to solve the lunch issue. According to the arrangement, there are sisicompetitors in the i-th block. Limited to the size of table, bibi bags of lunch including breads, sausages and milk would be put in the i-th block. As a result, some competitors need to move to another block to access lunch. However, the playground is temporary, as a result there would be so many wires on the path. 
For the i-th path, the wires have been stabilized at first and the first competitor who walker through it would not break the wires. Since then, however, when a person go through the i - th path, there is a chance of pipi to touch 
the wires and affect the whole networks. Moreover, to protect these wires, no more than cici competitors are allowed to walk through the i-th path. 
Now you need to find a way for all competitors to get their lunch, and minimize the possibility of network crashing. 

Input

The first line of input contains an integer t which is the number of test cases. Then t test cases follow. 
For each test case, the first line consists of two integers N (N ≤ 100) and M (M ≤ 5000). Each of the next N lines contains two integers si and bibi (sisi , bibi ≤ 200). 
Each of the next M lines contains three integers uiui , vivi and ci(cici(ci ≤ 100) and a float-point number pipi(0 < pipi < 1). 
It is guaranteed that there is at least one way to let every competitor has lunch.

Output

For each turn of each case, output the minimum possibility that the networks would break down. Round it to 2 digits.

Sample Input

1
4 4
2 0
0 3
3 0
0 3
1 2 5 0.5
3 2 5 0.5
1 4 5 0.5
3 4 5 0.5

Sample Output

0.50

题目大意:

给出一张图,图上的每个点有si个选手,bi份食物,有的点之间用有最多可以通过ci个选手,除第一次外每次通过选手都有pi概率使全图断裂的边连接。问如何让选手走动可以使他们都吃到东西而且全图断裂的可能最小。

思路:

图断裂的概率为1-\prod(1-pi)^(wi-1),wi为通过的人数。要求概率最小,那就是求\prod(1-pi)^(wi-1)的最大值,用log处理之后这就是一个简单的加法处理了。直接套用MCMF的板子就完事了。

反思:最近练了很短网络流了,可是今天做这题的时候还是没有做出来。反思一下自己

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值