poj 3308 Paratroopers
http://poj.org/problem?id=3308
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
#define maxn 10000
using namespace std; const int inf=<<;
int n,m,l,x,y;
double c,f;
double cap[][],flow[][];
int p[];
double a[]; void EK(int s)
{
queue<int>q;
memset(flow,,sizeof(flow));
f=;
for(; ;)
{
memset(a,,sizeof(a));
memset(p,-,sizeof(p));
a[s]=inf;
q.push(s);
while(!q.empty())
{
int u=q.front();
q.pop();
for(int v=; v<=m+n+; v++)
{
if(!a[v]&&cap[u][v]>flow[u][v])
{
p[v]=u;
q.push(v);
a[v]=min(a[u],cap[u][v]-flow[u][v]);
}
}
}
if(a[m+n+]==) break;
for(int u=m+n+; u!=; u=p[u])
{
flow[p[u]][u]+=a[m+n+];
flow[u][p[u]]-=a[m+n+];
}
f+=a[m+n+];
}
} int main()
{
int T;
scanf("%d",&T);
while(T--)
{
memset(cap,,sizeof(cap));
scanf("%d%d%d",&m,&n,&l);
for(int i=;i<=m; i++)
{
scanf("%lf",&c);
cap[][i]=log(c);
}
for(int i=m+; i<=m+n; i++)
{
scanf("%lf",&c);
cap[i][m+n+]=log(c);
}
for(int i=; i<l; i++)
{
scanf("%d%d",&x,&y);
cap[x][m+y]=inf;
}
f=;
EK();
printf("%.4f\n",exp(f));
}
return ;
}
poj 3308 Paratroopers的更多相关文章
- POJ - 3308 Paratroopers(最大流)
1.这道题学了个单词,product 还有 乘积 的意思.. 题意就是在一个 m*n的矩阵中,放入L个敌军的伞兵,而我军要在伞兵落地的瞬间将其消灭.现在我军用一种激光枪组建一个防御系统,这种枪可以安装 ...
- POJ 3308 Paratroopers(最小点权覆盖)(对数乘转加)
http://poj.org/problem?id=3308 r*c的地图 每一个大炮可以消灭一行一列的敌人 安装消灭第i行的大炮花费是ri 安装消灭第j行的大炮花费是ci 已知敌人坐标,同时消灭所有 ...
- POJ 3308 Paratroopers(最小割EK(邻接表&矩阵))
Description It is year 2500 A.D. and there is a terrible war between the forces of the Earth and the ...
- POJ 3308 Paratroopers 最大流,乘积化和 难度:2
Paratroopers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7267 Accepted: 2194 Desc ...
- POJ - 3308 Paratroopers (最小点权覆盖)
题意:N*M个格点,K个位置会有敌人.每行每列都有一门炮,能打掉这一行(列)上所有的敌人.每门炮都有其使用价值.总花费是所有使用炮的权值的乘积.求最小的总花费. 若每门炮的权值都是1,就是求最小点覆盖 ...
- POJ 3308 Paratroopers(最大流最小割の最小点权覆盖)
Description It is year 2500 A.D. and there is a terrible war between the forces of the Earth and the ...
- poj 3308 Paratroopers(二分图最小点权覆盖)
Paratroopers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8954 Accepted: 2702 Desc ...
- POJ 3308 Paratroopers (对数转换+最小点权覆盖)
题意 敌人侵略r*c的地图.为了消灭敌人,可以在某一行或者某一列安置超级大炮.每一个大炮可以瞬间消灭这一行(或者列)的敌人.安装消灭第i行的大炮消费是ri.安装消灭第j行的大炮消费是ci现在有n个敌人 ...
- POJ 3308 Paratroopers(最小割EK)
题目链接 题意 : 有一个n*m的矩阵,L个伞兵可能落在某些点上,这些点的坐标已知,需要在某些位置安上一些枪,然后每个枪可以将一行或者一列的伞兵击毙.把这种枪安装到不同行的行首.或者不同列的列首,费用 ...
随机推荐
- python通过SMTP发送邮件失败,报错505/535
python通过SMTP发送邮件失败:错误1:smtplib.SMTPAuthenticationError: (550, b'User has no permission') 我们使用pyth ...
- XMPPFrameWork IOS 开发(一)xmpp简介
原始地址:XMPPFrameWork IOS 开发(一) XMPP : The Extensible Messaging and Presence Protocol 中文全称: 可扩展通讯和表示协议 ...
- 诡异的TNS-12541:TNS:nolistener
诡异的TNS-12541:TNS:nolistener OS:Microsoft Windows 2003 Ent ...
- MatLab计算图像圆度
本文所述方法可以检测同一图像中的多个圆形(准确的说,应该是闭合图像). 在Matlab2010a中可以实现. 附录效果图: %颗粒圆度 clear;close all; %% %读取源图像 I = i ...
- android bitmap的 一些简单操作
/** 获取 drawable 的图片 可以循环 1.图名 2.drawable 3.包名 **/ int imgid = getResources().getIdentifier("ic_ ...
- 第五章:最后一步准备,1.8的Json模型、状态描述机制详解
<基于1.8 Forge的Minecraft mod制作经验分享> 1.8的所有纹理材质都需要一个Json来对其描述,这一块感觉是各大神的教程里面涉及最少最浅的,我就斗胆在这分享下我研究了 ...
- Day10 - Python协程、异步IO、redis缓存、rabbitMQ队列
Python之路,Day9 - 异步IO\数据库\队列\缓存 本节内容 Gevent协程 Select\Poll\Epoll异步IO与事件驱动 Python连接Mysql数据库操作 RabbitM ...
- 给方法传递参数:ref参数和out参数
/*--------------------------------------------------- 给方法传递参数:ref参数和out参数 (P106) ------------------- ...
- 没有懂的leetcode
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...
- 命令行命令mvn
在cmd命令行敲击mvn clean install 默认读取的maven配置文件是D:\software\apache-maven-3.2.1\conf\settings.xml 这个文件里面配置有 ...