Description
Freda's Castle--
"Freda, some intruders were found outside the castle!" ”
"Meow ... Just explored the number of plans for the castle building, I want to rest for a while. lala~ "
"But the invaders are approaching the castle!" said the man. ”
"Don't worry, Rainbow, you see, this is what I just designed the missile defense system to say ~"
"Hello ... Don't sell cute ... "
The Freda Controls N-block towers that can launch missiles. Each tower has a sufficient number of missiles, but each tower can only launch one at a time. When launching a missile, it takes T1 seconds for the missile to be shot out of the tower, and the missile's defense tower needs T2 minutes to cool off after the missile is launched.
All missiles have the same uniform speed of Flight V, and will be the shortest path along the distance to hit the target. When calculating the distance distance the tower to the target, you only need to calculate the horizontal distance, ignoring the height of the missile flight. The time the missile flies in the air is (distance/v) minutes, and the missile can be destroyed immediately after it reaches its target.
Now, given the coordinates of the N-Block missile defense tower, the coordinates of the M-Intruders, T1, T2, and V, you need to ask for at least a few minutes to repel all intruders.
Input
The first row of five positive integers n,m,t1,t2,v.
The next m line is two integers per line, representing the coordinates of the intruder.
The next n rows are two integers per line, representing the coordinates of the tower.
Output
Outputs a real number that indicates how many minutes it takes to hit all intruders, rounding up six decimal places.
Two-point answer, network flow judgment
#include <cstdio>#include<cmath>Const intn=1000000;intn,m,s,t;intmx[ -],my[ -],nx[ -],ny[ -];intEs[n],enx[n],e0[n],ep,h[n],q[n],ev[n];Doublet1,t2,v;BOOLBFs () { for(intI=1; i<=t;i++) h[i]=0; intQl=0, qr=0; H[Q[QR++]=s]=1; while(ql!=qr) { intw=q[ql++]; for(intI=e0[w];i;i=enx[i])if(Ev[i]) {intu=Es[i]; if(!h[u]) h[q[qr++]=u]=h[w]+1; } } returnh[t];}intDfsintWintf) { if(w==t)returnF; intC,used=0; for(intI=e0[w];i;i=enx[i])if(Ev[i]) {intu=Es[i]; if(h[u]!=h[w]+1)Continue; C=f-used; if(C>ev[i]) c=Ev[i]; C=DFS (U,C); Ev[i]-=C; Ev[i^1]+=C; Used+=C; if(f==used)returnF; } H[w]=0; returnused;} InlinevoidAdde (intAintb) {ES[EP]=b;enx[ep]=e0[a];ev[ep]=1; e0[a]=ep++; ES[EP]=a;enx[ep]=e0[b];ev[ep]=0; e0[b]=ep++;}BOOLChkDoublet) {EP=2; S=n*m+m+1; t=s+1; for(intI=1; i<=t;i++) e0[i]=0; for(intI=1; i<=n;i++){ for(intk=0; k<m;k++) {Adde (S, (i-1) *m+k+1); } } for(intI=1; i<=m;i++) Adde (n*m+i,t); for(intI=1; i<=n;i++){ for(intj=1; j<=m;j++){ Doublex=mx[j]-nx[i],y=my[j]-Ny[i]; DoubleTM=SQRT (x*x+y*y)/v; if(tm>t)Continue; for(intk=0; k<m;k++)if(tm+t1+ (T1+T2) *k<=t) {Adde ((i-1) *m+k+1, n*m+j); } } } intans=0; while(BFS ())) Ans+=dfs (S,0x3f3f3f3f); returnans==m;}intMain () {scanf ("%D%D%LF%LF%LF",&n,&m,&t1,&t2,&v); for(intI=1; i<=m;i++) scanf ("%d%d", mx+i,my+i); for(intI=1; i<=n;i++) scanf ("%d%d", nx+i,ny+i); T1/= -.; DoubleL=0, r=1e5; for(intI=0;i< -; i++){ Doublem= (l+r) *.5; if(CHK (M)) R=l; ElseL=M; } printf ("%.6f\n", L); return 0;}
bzoj3035: Missile Defense Tower