The topic probably said that there is m person to cross a wide W river, the longest long jump distance is D, the river has n garbage heap, each rubbish heap has coordinates and the same time can accommodate the number of people, ask everyone to jump at least several times to jump to the opposite shore.
It's another question. The maximum flow based on time split.
Two minutes to build the capacity of the network to determine: According to the time of each garbage heap demolition, and then split into two points in the middle of the capacity for the same time can accommodate the number of sides, all T-moment points to all the t+1 moment can reach the point of the edge.
In addition, it can be known that if you can reach the other side of the worst case of total need to jump n+m. Because the worst case of each garbage heap can only accommodate one person, and must jump all the rubbish heap to reach the other side, then the first person needs to jump m+1 times, the back n-1 people follow the front that person jump, each jump once there is a new person to reach the other side, but also need n-1 times, a total of n+m times.
1#include <cstdio>2#include <cstring>3#include <queue>4#include <algorithm>5 using namespacestd;6 #defineINF (1<<30)7 #defineMAXN 111118 #defineMAXM 6666669 Ten structedge{ One intV,cap,flow,next; A }EDGE[MAXM]; - intVs,vt,ne,nv; - intHEAD[MAXN]; the - 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)); -level[vt]=0; ingap[level[vt]]++; -queue<int>que; to Que.push (VT); + while(!Que.empty ()) { - intu=Que.front (); Que.pop (); the for(intI=head[u]; i!=-1; I=Edge[i].next) { * intv=edge[i].v; $ if(level[v]!=-1)Continue;Panax Notoginsenglevel[v]=level[u]+1; -gap[level[v]]++; the Que.push (v); + } A } the } + - intPRE[MAXN]; $ intCUR[MAXN]; $ intIsap () { - BFS (); -memset (pre,-1,sizeof(pre)); thememcpy (Cur,head,sizeof(head)); - intu=pre[vs]=vs,flow=0, aug=INF;Wuyigap[0]=NV; the while(level[vs]<NV) { - BOOLflag=false; Wu for(int&i=cur[u]; i!=-1; I=Edge[i].next) { - intv=edge[i].v; About if(Edge[i].cap!=edge[i].flow && level[u]==level[v]+1){ $flag=true; -pre[v]=u; -u=v; - //aug= (Aug==-1?edge[i].cap:min (Aug,edge[i].cap)); AAug=min (aug,edge[i].cap-edge[i].flow); + if(v==VT) { theflow+=; - for(u=pre[v]; V!=vs; v=u,u=Pre[u]) { $edge[cur[u]].flow+=; theedge[cur[u]^1].flow-=; the } the //Aug=-1; theaug=INF; - } in Break; the } the } About if(flag)Continue; the intMinlevel=NV; the for(intI=head[u]; i!=-1; I=Edge[i].next) { the intv=edge[i].v; + if(Edge[i].cap!=edge[i].flow && level[v]<minlevel) { -Minlevel=Level[v]; thecur[u]=i;Bayi } the } the if(--gap[level[u]]==0) Break; -level[u]=minlevel+1; -gap[level[u]]++; theu=Pre[u]; the } the returnflow; the } - intx[ -],y[ -],c[ -]; the intn,m,d,w; the BOOLisOKintTime ) { thevs=n*time*2+1; vt=vs+1; nv=vt+1; Ne=0;94memset (head,-1,sizeof(head)); theAddedge (vs,n*time*2, m); the for(intI=0; i<n; ++i) { the if(y[i]<=d) {98 for(intt=0; t<time; ++t) Addedge (n*time*2, i*time+t,m); About } - if(w-y[i]<=d) {101 for(intt=0; t<time; ++t) Addedge (i*time+t+n*time,vt,m);102 }103 }104 for(intI=0; i<n; ++i) { the for(intt=0; t<time; ++t) Addedge (i*time+t,i*time+t+n*time,c[i]);106 for(intt=0; t<time-1; ++t) {107Addedge (i*time+t+n*time,i*time+t+1, m);108 for(intj=0; j<n; ++j) {109 if(I==j | | y[i]>y[j])Continue; the if((X[i]-x[j]) * (X[i]-x[j]) + (Y[i]-y[j]) * (Y[i]-y[j]) <=d*d) Addedge (i*time+t+n*time,j*time+t+1, m);111 } the }113 } the returnISAP () = =m; the } the intMain () {117scanf"%d%d%d%d",&n,&m,&d,&W);118 for(intI=0; i<n; ++i) {119scanf"%d%d%d", x+i,y+i,c+i); - }121 if(d>=W) {122Putchar ('1');123 return 0;124 } the intL=1, r=n+m+1;126 while(l<R) {127 intMid=l+r>>1; - if(isOK (mid)) r=mid;129 ElseL=mid+1; the }131 if(l==n+m+1) puts ("Impossible"); the Elseprintf"%d", L +1);133 return 0;134}
SGU438 the glorious Karlutka river =) (maximum flow)