The topic probably said that there is a simple graph of n-point M-side, each side can only allow a certain amount of goods through. To allow the X-Bear to deliver goods from 1 to n, each bear is transported and transported in the same weight, asking for the maximum value of the weight.
The two-part weight judgment is established.
If the weight is known, then how many bears can be found on each side, that is, the capacity of the side divided by the weight. And judging whether the X-Bear can go to 1 to N is determined by the maximum flow.
Then the problem is OK--but pay attention to the accuracy--there will be a burst int!. I really can't believe it.
1#include <cstdio>2#include <cstring>3#include <cmath>4#include <queue>5#include <algorithm>6 using namespacestd;7 #defineINF (1<<30)8 #defineMAXN 55559 #defineMAXM 11111Ten One structedge{ A intV,cap,flow,next; - }EDGE[MAXM]; - intVs,vt,ne,nv; the intHEAD[MAXN]; - - voidAddedge (intUintVintcap) { -Edge[ne].v=v; Edge[ne].cap=cap; edge[ne].flow=0; +Edge[ne].next=head[u]; head[u]=ne++; -Edge[ne].v=u; edge[ne].cap=0; edge[ne].flow=0; +EDGE[NE].NEXT=HEAD[V]; head[v]=ne++; A } at - intLEVEL[MAXN]; - intGAP[MAXN]; - voidBFs () { -memset (level,-1,sizeof(level)); -Memset (Gap,0,sizeof(GAP)); inlevel[vt]=0; -gap[level[vt]]++; toqueue<int>que; + Que.push (VT); - while(!Que.empty ()) { the intu=Que.front (); Que.pop (); * for(intI=head[u]; i!=-1; I=Edge[i].next) { $ intv=edge[i].v;Panax Notoginseng if(level[v]!=-1)Continue; -level[v]=level[u]+1; thegap[level[v]]++; + Que.push (v); A } the } + } - $ intPRE[MAXN]; $ intCUR[MAXN]; - intIsap () { - BFS (); thememset (pre,-1,sizeof(pre)); -memcpy (Cur,head,sizeof(head));Wuyi intu=pre[vs]=vs,flow=0, aug=INF; thegap[0]=NV; - while(level[vs]<NV) { Wu BOOLflag=false; - for(int&i=cur[u]; i!=-1; I=Edge[i].next) { About intv=edge[i].v; $ if(Edge[i].cap!=edge[i].flow && level[u]==level[v]+1){ -flag=true; -pre[v]=u; -u=v; A //aug= (Aug==-1?edge[i].cap:min (Aug,edge[i].cap)); +Aug=min (aug,edge[i].cap-edge[i].flow); the if(v==VT) { -flow+=; $ for(u=pre[v]; V!=vs; v=u,u=Pre[u]) { theedge[cur[u]].flow+=; theedge[cur[u]^1].flow-=; the } the //Aug=-1; -aug=INF; in } the Break; the } About } the if(flag)Continue; the intMinlevel=NV; the for(intI=head[u]; i!=-1; I=Edge[i].next) { + intv=edge[i].v; - if(Edge[i].cap!=edge[i].flow && level[v]<minlevel) { theMinlevel=Level[v];Bayicur[u]=i; the } the } - if(--gap[level[u]]==0) Break; -level[u]=minlevel+1; thegap[level[u]]++; theu=Pre[u]; the } the returnflow; - } the the int from[MAXN],TO[MAXN],CAP[MAXN]; the intn,m,x;94 BOOLisOKDoublemid) { theXss0; Vt=n; nv=n+1; Ne=0; thememset (head,-1,sizeof(head)); theAddedge (VS,1, x);98 for(intI=0; i<m; ++i) { About Long LongTmp= (Long Long) (cap[i]/mid+1e-9); - if(Tmp>inf) tmp=INF;101Addedge ( from[i],to[i],tmp];102 }103 returnISAP () = =x;104 } the 106 intMain () {107scanf"%d%d%d",&n,&m,&x);108 for(intI=0; i<m; ++i) {109scanf"%d%d%d", from+i,to+i,cap+i); the }111 DoubleL=0, r=1000000, mid; the while(Fabs (r-l) >1e-9){113Mid= (L+R)/2; the if(mid==0) Break; the if(isOK (mid)) { theL=mid;117}Else{118R=mid;119 } - }121printf"%f\n", mid*x);122 return 0;123}
Codeforces 653D Delivery Bears (maximum flow)