题意翻译

有n 个人去执行n 个任务,每个人执行每个任务有不同的成功率,每个人只能执行一个任务,求所有任务都执行的总的成功率。

输入第一行,一个整数n (1≤n≤20 ),表示人数兼任务数。接下来n 行每行n 个数,第i 行第j 个数表示第i 个人去执行第j 个任务的成功率(这是一个百分数,在0 到100 间)。

输出最大的总成功率(这应也是一个百分数)

题目描述

Everyone knows of the secret agent double-oh-seven, the popular Bond (James Bond). A lesser known fact is that he actually did not perform most of his missions by himself; they were instead done by his cousins, Jimmy Bonds. Bond (James Bond) has grown weary of having to distribute assign missions to Jimmy Bonds every time he gets new missions so he has asked you to help him out. Every month Bond (James Bond) receives a list of missions. Using his detailed intelligence from past missions, for every mission and for every Jimmy Bond he calculates the probability of that particular mission being successfully completed by that particular Jimmy Bond. Your program should process that data and find the arrangement that will result in the greatest probability that all missions are completed successfully. Note: the probability of all missions being completed successfully is equal to the product of the probabilities of the single missions being completed successfully.

输入输出格式

输入格式:

The first line will contain an integer N, the number of Jimmy
Bonds and missions (1 ≤ N ≤ 20).
The following N lines will contain N integers between 0 and 100,
inclusive. The j-th integer on the ith line is the probability that
Jimmy Bond i would successfully complete mission j, given as a
percentage.

输出格式:

Output the maximum probability of Jimmy Bonds successfully completing all the missions, as a percentage.

输入输出样例

输入样例#1:

2
100 100
50 50
输出样例#1:

50.000000
输入样例#2:

2
0 50
50 0
输出样例#2:

25.00000
输入样例#3:

3
25 60 100
13 0 50
12 70 90
输出样例#3:

9.10000

说明

Clarification of the third example: If Jimmy bond 1 is assigned the 3rd mission, Jimmy Bond 2 the 1st mission and Jimmy Bond 3 the 2nd mission the probability is: 1.0 0.13 0.7 = 0.091 = 9.1%. All other arrangements give a smaller probability of success. Note: Outputs within ±0.000001 of the official solution will be accepted.

Solution:

  本题SB费用流,裸的没话讲咯。

  读题后不难构建一个带权二分图的模型,于是KM啦,我们直接跑最大费用最大流,坑点在于直接累乘费用会爆精度(long double都炸了),一个巧妙的解决方法是建图时把费用设为$\ln c$,这样跑费用流就把乘法变为加法,最后只要输出$e^{cost_{max}}$就好了(注意特判$cost_{max}=0$的情况)。

代码:

/*Code by 520 -- 9.4*/
#include<bits/stdc++.h>
#define il inline
#define ll long long
#define RE register
#define For(i,a,b) for(RE int (i)=(a);(i)<=(b);(i)++)
#define Bor(i,a,b) for(RE int (i)=(b);(i)>=(a);(i)--)
using namespace std;
const int N=,inf=;
int s,t,n,maxf,h[N],to[N],net[N],w[N],cnt=,pre[N],maxn[N];
long double ans,dis[N],c[N];
bool vis[N]; il void add(int u,int v,int fl,double co){
to[++cnt]=v,net[cnt]=h[u],w[cnt]=fl,c[cnt]=co,h[u]=cnt;
to[++cnt]=u,net[cnt]=h[v],w[cnt]=,c[cnt]=-co,h[v]=cnt;
} il bool spfa(){
queue<int>q;
For(i,,t) dis[i]=-inf;
dis[s]=,q.push(s),maxn[s]=inf;
while(!q.empty()){
RE int u=q.front();q.pop();vis[u]=;
for(RE int i=h[u];i;i=net[i])
if(dis[to[i]]<dis[u]+c[i]&&w[i]){
dis[to[i]]=dis[u]+c[i],pre[to[i]]=i,
maxn[to[i]]=min(maxn[u],w[i]);
if(!vis[to[i]])vis[to[i]]=,q.push(to[i]);
}
}
return dis[t]!=-inf;
} il void update(){
int p=t;
while(p!=s){
RE int i=pre[p];
w[i]-=maxn[t],w[i^]+=maxn[t];
p=to[i^];
}
ans+=dis[t];
} int main(){
scanf("%d",&n),t=n<<|;
double x;
For(i,,n) For(j,,n) scanf("%lf",&x),add(i,j+n,,log(x/));
For(i,,n) add(s,i,,),add(i+n,t,,);
while(spfa())update();
printf("%.6Lf",(ans?exp(ans)*:));
return ;
}

P4329 [COCI2006-2007#1] Bond的更多相关文章

  1. 【刷题】洛谷 P4329 [COCI2006-2007#1] Bond

    题意翻译 有 \(n\) 个人去执行 \(n\) 个任务,每个人执行每个任务有不同的成功率,每个人只能执行一个任务,求所有任务都执行的总的成功率. 输入第一行,一个整数 \(n\) ( \(1\leq ...

  2. [洛谷P4329][COCI2006-2007#1] Bond

    题目大意:有$n$个人有$n$个任务,每个人执行每个任务有不同的成功率,每个人只能执行一个任务,求所有任务都执行的总的成功率. 题解:可以跑最大费用最大流,把成功率取个$log$,最后$exp$回去就 ...

  3. Configure a VLAN (on top of a bond) with NetworkManager (nmcli) in RHEL7

    not on top of a bond Environment Red Hat Enterprise Linux 7 NetworkManager Issue Need an 802.1q VLAN ...

  4. poi读取excel模板,填充内容并导出,支持导出2007支持公式自动计算

    /** * 版权所有(C) 2016 * @author www.xiongge.club * @date 2016-12-7 上午10:03:29 */ package xlsx; /** * @C ...

  5. BZOJ 2007: [Noi2010]海拔

    2007: [Noi2010]海拔 Time Limit: 20 Sec  Memory Limit: 552 MBSubmit: 2410  Solved: 1142[Submit][Status] ...

  6. cnentos中进行bond网卡配置,一切配置无问题,就是ping不通宿主机

    服务器网口绑定   1. ifcfg-bond0   DEVICE=bond0 ONBOOT=yes IPADDR=192.168.100.64 NETMASK=255.255.255.0   2. ...

  7. Microsoft开源跨平台的序列化库——Bond

    上个月Microsoft开源了Bond,一个跨平台的模式化数据处理框架.Bond支持跨语言的序列化/反序列化,支持强大的泛型机制能够对数据进行有效地处理.该框架在Microsoft公司内部的高扩展服务 ...

  8. 开源WinForms界面开发框架Management Studio 选项卡文档 插件 Office 2007蓝色风格 后台线程

    Management Studio是我在WinForms小项目开发过程中搭建起来的一个插件式结构的应用程序框架,因为简单灵活又容易扩展,现在将它开源供读者参考. 跑起来的效果图如下所示,具备选项卡式多 ...

  9. [转载]Linux Bond的原理及其不足

    本文转自http://www.yunweipai.com/archives/1969.html 支持原创.尊重原创,分享知识! 在企业及电信Linux服务器环境上,网络配置都会使用Bonding技术做 ...

随机推荐

  1. 分享一个DataTable转List强类型的类库

    类库扩展自Datatable,可以直接用Datatable.ToList<T>()进行转换.为了方便把DataReader装入Datatable,开扩展了一个LoadForReader(t ...

  2. Android Studio 导入别人项目时候遇见的问题“Gradle DSL method not found: 'compile()'”

    Gradle DSL method not found: 'compile() 遇见这个问题截图: 解决: 在项目的根目录的build.gradle文件中是不是用了compile方法 如果有的话,剪切 ...

  3. python的字符串格式化

    1.python到底有那几种字符串格式化模块? python有3种格式化字符串的方法: 传统的%字符串格式符 str.format函数 字符串模版template 新的python 3.6+还提供了新 ...

  4. React Native移动开发实战-4-Android平台的适配原理

    打开Android开发工具Android Studio,选择菜单 Open an existing AndroidStudio project,打开ch04项目的android文件夹,如图5.8所示. ...

  5. SmartRaiden 和 Lighting Network 进行去中心化跨链原子资产交换

    作者介绍 虫洞社区·签约作者 steven bai 前言 如果能够进行以太坊和比特币跨链原子资产交换,是不是一件很酷的事情? 目前链下的扩容方式有很多,最广为人知的就是比特币的闪电网络和以太坊的雷电网 ...

  6. Python图形界面开发—wxPython库的布局管理及页面切换

    前言 wxPython是基于Python的跨平台GUI扩展库,对wxWidgets( C++ 编写)封装实现.GUI程序的开发中界面布局是很重要的一个部分,合理的页面布局能够给予用户良好使用体验.虽然 ...

  7. c# 写文件注意问题及用例展示

    以txt写string举例,正确代码如下: private void xie() { FileStream fs = new FileStream("1.txt", FileMod ...

  8. Percona XtraDB Cluster 5.7

    附加:相关在线文档https://www.percona.com/software/documentation 安装要求: 1.root权限2.保证开放3306.4444.4567.4568端口3.关 ...

  9. 修改MyEclipse工作空间

    MyEclipse如何更改工作空间,MyEclipse是java开发常用工具,在开发的过程中我们会经常切换工作空间来切换项目内容,初学者来说有必要讲一下如何切换工作空间 工具/原料   MyEclip ...

  10. spring冲刺阶段之团队工作总结

    一.小组成员: 王俊凯(项目经理) 罗林杰(产品负责人) 王逸辉(Master) 罗凯杰 二.任务分配情况 王俊凯:生成题目的代码编写并提出编写意见 罗林杰:负责把按钮和界面内容连接到代码上及主要代码 ...