poj 3308 Paratroopers 最小割—最大流
来源:互联网 发布:bangumi 知乎 编辑:程序博客网 时间:2024/05/22 04:51
和方格取数类似的建图,基本上读完题就能看出来了,简单的最小割,至于取对数是常用方法,没什么好说的
网络流一般都是int的,double只要加一个eps精度判定就可以了~~
一次性编译 + 一次性ac~~看来我变强了。。。︿( ̄︶ ̄)︽( ̄︶ ̄)︿飞.飞.飞.
#include<iostream>#include<vector>#include<algorithm>#include<cstdio>#include<queue>#include<stack>#include<string>#include<map>#include<set>#include<cmath>#include<cassert>#include<cstring>#include<iomanip>using namespace std;#ifdef _WIN32#define i64 __int64#define format "%I64d\n"#else#define i64 long long#define format "%lld\n"#endif#define CC(m,what)memset(m,what,sizeof(m))#define FOR(i,a,b)for( int i = (a) ; i <= (b) ; i ++)#define FF(i,a)for( int i = 0 ; i < (a) ; i ++)#define FFD(i,a)for( int i = (a)-1 ; i >= 0 ; i --)#define SS(a)scanf("%d",&a)#define LL(a)((a)<<1)#define RR(a)(((a)<<1)+1)#define PP(n,m,a)puts("---");FF(i,n){FF(j,m)cout << a[i][j] << ' ';puts("");}#define pb push_back#define CL(Q) while(!Q.empty())Q.pop()#define MM(name,what) memset(name,what,sizeof(name))#define readfreopen("in.txt","r",stdin)#define writefreopen("out.txt","w",stdout)const int inf = 0x3f3f3f3f;const double oo = 10e9;const double eps = 1e-10;const double PI = acos(-1.0);const int maxn=111;const int end=110;struct zz{ int from; int to; int id; double c;}zx,tz;int T,m,n,l,tx,ty;double td;double sx[maxn];double sy[maxn];vector<zz>g[maxn];queue<int>q;int cen[maxn];inline void init(){ FF(i,maxn) g[i].clear(); return ;}bool bfs(){ CL(q); MM(cen,-1); cen[0] = 0; q.push(0); int now,to; while(!q.empty()) { now = q.front(); q.pop(); FF(i,g[now].size()) { to = g[now][i].to; if( g[now][i].c > eps && cen[to] == -1) { cen[to] = cen[now] + 1; q.push(to); } } } return cen[end] != -1; }double dfs(double flow = oo , int now = 0 ){ if(now == end) { return flow; } double temp,sum=0.0; int to; FF(i,g[now].size()) { to = g[now][i].to; if( cen[to] == cen[now] + 1 && flow - sum > eps && g[now][i].c > eps ) { temp = dfs ( min ( flow - sum , g[now][i].c ) , to ); sum += temp; g[now][i].c -= temp; g[to][g[now][i].id].c += temp; } } if(sum < eps) cen[now] = -1; return sum;}double dinic(){ double ans=0.0; while( bfs() ) { ans += dfs(); } ans = exp (ans); return ans;}int main(){ cin>>T; while(T--) { cin>>m>>n>>l; init(); for(int i=1;i<=m;i++) { cin>>td; td = log(td); sx[i] = td; } for(int i=1;i<=n;i++) { cin>>td; td = log(td); sy[i] = td; } FOR(i,1,m) { zx.from = 0; zx.to = i; zx.c = sx[i]; zx.id = g[i].size(); g[0].pb(zx); swap (zx.from , zx.to); zx.c = 0; zx.id = g[0].size() - 1; g[i].pb(zx); } FOR(i,1,n) { zx.from = 50 + i; zx.to = end; zx.c = sy[i]; zx.id = g[end].size(); g[50+i].pb(zx); swap (zx.from , zx.to); zx.c = 0; zx.id = g[50+i].size() - 1; g[end].pb(zx); } FOR(i,1,l) { cin>>tx>>ty; zx.from = tx; zx.to = ty + 50; zx.c = oo; zx.id = g[zx.to].size(); g[tx].pb(zx); swap (zx.from , zx.to); zx.c=0; zx.id = g[tx].size() - 1; g[zx.from].pb(zx); } cout.setf(ios::fixed); cout<< setprecision(4) << dinic() <<endl; } return 0; }
- POJ 3308 Paratroopers 最小割、最大流
- poj 3308 Paratroopers 最小割—最大流
- POJ 3308 Paratroopers //最小割
- 【最小割】POJ-3308 Paratroopers
- (最小割)poj 3308 Paratroopers
- POJ 3308 Paratroopers (二分图最小点权覆盖 -> 最小割 -> 最大流)
- POJ3308 Paratroopers 最大流最小割
- poj 3308 Paratroopers(网络流 最小割 dinic模板)
- poj 3308 Paratroopers(最小割)
- POJ 3308 Paratroopers(最小割+Dinic)
- POJ 3308 Paratroopers (最小割)
- POJ 3308--Paratroopers【 最小点权覆盖 && 最小割】
- [POJ 3308]Paratroopers[最大流]
- (POJ3308)Paratroopers 最大流最小割,建图,模板题
- zoj 2874 & poj 3308 Paratroopers (最小割)
- poj 3308 zoj 2874 Paratroopers(最小割)
- POJ 3308 Paratroopers(最小割EK(邻接表&矩阵))
- POJ 3308 Paratroopers(最小割+对数降级)
- How to register a keyboard shortcut (hot key) in a .NET Windows Forms Application
- zt:-职业生涯步步高:一位资深经理人的职业生涯感悟
- STL之Trim
- C99标准 数据类型以及后缀
- 电影 《狂暴飞车》
- poj 3308 Paratroopers 最小割—最大流
- 自定义输出宏替代NSLog
- SQLServer2005宝典学习笔记(数据操纵部分)
- Android牟利之道(一)--界面嵌入有米广告
- PC上远程调试Android Python Script(2)
- ubuntu的 问 题
- MFC隐藏线程窗口并把输出返回的方法
- [小说连载]张小庆,在路上(29)-谢谢,再见
- dxlib在vs2008中的配置