BZOJ 1580
直接解析算出每段的时间然后模拟即可
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <queue> 6 #include <vector> 7 #include <cmath> 8 #define Pa pair<double,double> 9 #define mp make_pair 10 #define pb push_back 11 #define se second 12 #define fi first 13 14 using namespace std; 15 const int Maxn=50100; 16 const int Inf=0x3f3f3f3f; 17 int n,R,X,Y,Vx,Vy,P[Maxn],Q[Maxn],Vp[Maxn],Vq[Maxn],Ans; 18 vector<Pa> V; 19 inline int Sqr(int x) {return x*x;} 20 inline double Max(double x,double y) {return x>y?x:y;} 21 int main() 22 { 23 // freopen("c.in","r",stdin); 24 scanf("%d%d%d%d%d%d",&n,&R,&X,&Y,&Vx,&Vy); 25 for (int i=1;i<=n;i++) 26 { 27 scanf("%d%d%d%d",&P[i],&Q[i],&Vp[i],&Vq[i]); 28 P[i]-=X,Q[i]-=Y,Vp[i]-=Vx,Vq[i]-=Vy; 29 } 30 for (int i=1;i<=n;i++) 31 if (Vp[i]==0 && Vq[i]==0) 32 { 33 if (Sqr(P[i])+Sqr(Q[i])<=Sqr(R)) 34 V.pb(mp(0,Inf)); 35 } else 36 { 37 double Dis=-(P[i]*Vp[i]+Q[i]*Vq[i])/sqrt((Sqr(Vp[i])+Sqr(Vq[i]))); 38 if (R*R>=(double)Sqr(P[i])+(double)Sqr(Q[i])-Dis*Dis) 39 { 40 double tmp=sqrt(R*R-Sqr(P[i])-Sqr(Q[i])+Dis*Dis); 41 V.pb(mp(Max(Dis-tmp,0.0)/sqrt(Sqr(Vp[i])+Sqr(Vq[i])),(Dis+tmp)/sqrt(Sqr(Vp[i])+Sqr(Vq[i])))); 42 } 43 } 44 45 sort(V.begin(),V.end()); 46 priority_queue<double> T; 47 48 for (int i=0;i<V.size();i++) 49 { 50 T.push(-V[i].se); 51 while (!T.empty() && -T.top()<V[i].fi) T.pop(); 52 Ans=Max(Ans,T.size()); 53 } 54 printf("%d\n",Ans); 55 return 0; 56 }
BZOJ 1580
时间: 2024-11-03 05:39:03