Bzoj 1580
Calculate the time of each segment directly and then simulate
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <algorithm>5#include <queue>6#include <vector>7#include <cmath>8 #definePa pair<double,double>9 #defineMP Make_pairTen #definePB Push_back One #defineSe Second A #defineFi first - - using namespacestd; the Const intmaxn=50100; - Const intinf=0x3f3f3f3f; - intN,r,x,y,vx,vy,p[maxn],q[maxn],vp[maxn],vq[maxn],ans; -Vector<pa>V; +InlineintSQR (intx) {returnx*x;} -InlineDoubleMax (DoubleXDoubleY) {returnX>y?x:y;} + intMain () A { at //freopen ("c.in", "R", stdin); -scanf"%d%d%d%d%d%d",&n,&r,&x,&y,&vx,&Vy); - for(intI=1; i<=n;i++) - { -scanf"%d%d%d%d",&p[i],&q[i],&vp[i],&vq[i]); -p[i]-=x,q[i]-=y,vp[i]-=vx,vq[i]-=Vy; in } - for(intI=1; i<=n;i++) to if(vp[i]==0&& vq[i]==0) + { - if(SQR (P[i]) +SQR (Q[i]) <=SQR (R)) theV.PB (MP (0, INF)); *}Else $ {Panax Notoginseng Doubledis=-(P[i]*vp[i]+q[i]*vq[i])/sqrt ((SQR (vp[i]) +SQR (Vq[i] )); - if(R*r>= (Double) SQR (P[i]) + (Double) SQR (Q[i])-dis*Dis) the { + DoubleTmp=sqrt (R*R-SQR (P[i])-SQR (Q[i]) +dis*Dis); AV.PB (MP (Max (dis-tmp,0.0)/sqrt (SQR (Vp[i]) +SQR (Vq[i]), (dis+tmp)/sqrt (SQR (vp[i)) +SQR (Vq[i] ))); the } + } - $ sort (V.begin (), V.end ()); $priority_queue<Double>T; - - for(intI=0; I<v.size (); i++) the { -T.push (-v[i].se);Wuyi while(! T.empty () &&-t.top () <v[i].fi) T.pop (); theans=Max (Ans,t.size ()); - } Wuprintf"%d\n", Ans); - return 0; About}
Bzoj 1580
NOIP Computational geometry exercises before exams