poj 3308 Paratroopers
2024-08-22 01:41:09
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 ;
}
最新文章
- 8 种提升 ASP.NET Web API 性能的方法
- java中的wait(),notify(),notifyAll(),synchronized方法
- Haskell 参考资料
- JAVA代码中加了Try...Catch的执行顺序
- CentOS 6.4 下安装vsftpd
- Linux 批量解压gz包
- JavaScript- The Good Parts Chapter 5 Inheritance
- codeforces 132C Logo Turtle--- dp dfs
- 李洪强iOS开发Swift篇—07_函数
- JAVA入门[22]—thymeleaf
- .net Core EF统一配置实体类型
- python函数式编程之迭代器
- 【jQuery】 JQ和HTML以及JQ遍历元素
- Codeforces 1090A - Company Merging - [签到水题][2018-2019 Russia Open High School Programming Contest Problem A]
- Java学习之路-Hessian学习
- Verification of Model Transformations A Survey of the State-of-the-Art 模型转换的验证 对现状的调查
- 同步工具:CountDownLatch、CyclicBarrier和Semaphore
- DB2 rollforward 命令使用详解
- webpack 支持的模块方法
- 蜗牛慢慢爬 LeetCode 22. Generate Parentheses [Difficulty: Medium]