BZOJ1580: [Usaco2009 hol]cattle bruisers Killer Game

Source: Internet
Author: User

With Bessie as the reference, Bessie was fixed at the origin, and each killer was a circle in the center of a ray.

Solve the time interval where each killer can shoot Bessie, and then scan the line, time complexity $o (n\log N) $.

#include <cstdio> #include <algorithm> #include <cmath>using namespace std;typedef long Long ll;int n,r , bx,by,bvx,bvy,x,y,vx,vy,i,m,t,ans;double l,r,inf=1e9;struct p{double x;int y; P () {}p (double _x,int _y) {x=_x,y=_y;}} a[100010];inline BOOL CMP (P a,p b) {return a.x<b.x;} inline void Getlr (ll a,ll b,ll c) {  if (!a) {    if (c<=0) L=0,r=inf;else L=r=-inf;    return;  }  ll D=b*b-a*c*4;  if (d<0) {L=r=-inf;return;}  L= ( -1.0*b-sqrt (d))/2/a,r= ( -1.0*b+sqrt (d))/2/a;  if (r<0) L=r=-inf;  if (l<0) l=0;} int main () {  scanf ("%d%d%d%d%d%d", &n,&r,&bx,&by,&bvx,&bvy);  while (n--) {    scanf ("%d%d%d%d", &x,&y,&vx,&vy);    X-=bx,y-=by,vx-=bvx,vy-=bvy;    GETLR (vx*vx+vy*vy,2* (X*vx+y*vy), x*x+y*y-r*r);    if (r>-1) a[++m]=p (l,1), a[++m]=p (r,-1);  }  Sort (a+1,a+m+1,cmp);  for (i=1;i<=m;i++) Ans=max (ANS,T+=A[I].Y);  Return printf ("%d", ans), 0;}

  

BZOJ1580: [Usaco2009 hol]cattle bruisers Killer game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.