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 ;
}

最新文章

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

热门文章

  1. 查看Oracle最耗时的SQL
  2. jquery常用见的正则表达式
  3. poj 3422 (费用流)
  4. nginix 笔记
  5. Linux字符串函数集
  6. 简单图片banner轮播
  7. Linux sed命令在指定行前后添加内容
  8. 认识&lt;hr&gt;标签,添加水平横线
  9. CSS 布局Float 【1】
  10. css margin collapse