思路:
不被题目忽悠就是思路
二分一下max 判一下等不等于最大流
搞定
7 9 1
1 2 3
1 3 3
2 3 3
3 4 2
3 5 2
3 6 1
4 7 2
5 7 2
6 7 2
这里有组Bob是小数的例子
//By SiriusRen
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 105
#define M 2222
#define eps 1e-7
int n,m,p,xx[M],yy[M];
int first[N],vis[N],next[M],v[M],tot;
double w[M],l,r,Ans,zz[M];
void Add(int x,int y,double z){w[tot]=z,v[tot]=y,next[tot]=first[x],first[x]=tot++;}
void add(int x,int y,double z){Add(x,y,z),Add(y,x,0);}
void init(){memset(first,-1,sizeof(first)),tot=0;}
bool tell(){
memset(vis,-1,sizeof(vis)),vis[1]=0;
queue<int>q;q.push(1);
while(!q.empty()){
int t=q.front();q.pop();
for(int i=first[t];~i;i=next[i])
if(w[i]>eps&&vis[v[i]]==-1)
vis[v[i]]=vis[t]+1,q.push(v[i]);
}return ~vis[n];
}
double zeng(int x,double y){
if(x==n)return y;
double r=0;
for(int i=first[x];~i&&y>r;i=next[i])
if(w[i]>eps&&vis[v[i]]==vis[x]+1){
double t=zeng(v[i],min(y-r,w[i]));
w[i]-=t,w[i^1]+=t,r+=t;
}
if(r<eps)vis[x]=-1;
return r;
}
double flow(){
double tmp,ans=0;
while(tell())while((tmp=zeng(1,1000000.0))>eps)ans+=tmp;
return ans;
}
bool check(double mid){
init();
for(int i=1;i<=m;i++)
add(xx[i],yy[i],min(zz[i],mid));
double tmp=flow();
return Ans-tmp<eps;
}
int main(){
init(),scanf("%d%d%d",&n,&m,&p);
for(int i=1;i<=m;i++)
scanf("%d%d%lf",&xx[i],&yy[i],&zz[i]),add(xx[i],yy[i],zz[i]);
Ans=r=flow();
while(r-l>eps){
double mid=(l+r)/2;
if(check(mid))r=mid;
else l=mid;
}
printf("%d
%lf
",(int)Ans,l*p);
}
/*
7 9 1
1 2 3
1 3 3
2 3 3
3 4 2
3 5 2
3 6 1
4 7 2
5 7 2
6 7 2
*/