ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1093. Darts

Puzzled by test #5
Posted by deserts 12 Jul 2004 17:50
I'm sure my source code is perfect. But it never passed test #5. Can anyone help me?

#include <stdio.h>
#include <math.h>

int main()
{
        double  cx,cy,cz,nx,ny,nz,r,sx,sy,sz,vx,vy,vz,t;
        double  x,y,z;
        double  a,b,c;
        int     hit;
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",&cx,&cy,&cz,&nx,&ny,&nz,&r,&sx,&sy,&sz,&vx,&vy,&vz);
        b=nx*vx+ny*vy+nz*vz;
        c=nx*(sx-cx)+ny*(sy-cy)+nz*(sz-cz);
        a=-5*nz;
        if(b*b-4*a*c<-1e-8)
                printf("MISSED\n");
        else if((b+sqrt(b*b-4*a*c))/nz<-1e-8 && (b-sqrt(b*b-4*a*c))/nz<-1e-8)
                printf("MISSED\n");
        else
        {
                hit=0;
                t=(b-sqrt(b*b-4*a*c))/(10*nz);
                if(t>1e-8)
                {
                        x=sx+vx*t;
                        y=sy+vy*t;
                        z=sz+vz*t-5*t*t;
                        if(r-sqrt(pow(x-cx,2)+pow(y-cy,2)+pow(z-cz,2))>1e-8)
                                ++hit;
                }

                t=(b+sqrt(b*b-4*a*c))/(10*nz);
                if(t>1e-8)
                {
                        x=sx+vx*t;
                        y=sy+vy*t;
                        z=sz+vz*t-5*t*t;
                        if(r-sqrt(pow(x-cx,2)+pow(y-cy,2)+pow(z-cz,2))>1e-8)
                                ++hit;
                }
                if(hit)
                        printf("HIT\n");
                else
                        printf("MISSED\n");
        }
        return 0;
}
Re: Puzzled by test #5
Posted by deserts 12 Jul 2004 18:17
Solved!
What do you do if a = 0 ?
Posted by Vlad Veselov [PMG17, Vinnitsa - KNU, Kiev] 12 Jul 2004 18:19
I couldn't pass fifth test too, and I had mistake described above. Maybe, there is another mistake in your program.
Re: Puzzled by test #5
Posted by Smilodon_am 21 Mar 2009 17:25
The test 5 in TIMUS is the case when the trace of dart only touches the dartboard in one point (i.e. like the parabola touches the plane).

When I had understood this fact I got AC.

Edited by author 21.03.2009 17:26

Edited by author 21.03.2009 17:26
Re: Puzzled by test #5
Posted by Cebotari Vladislav 14 Dec 2016 19:56
So if it touches the plane should we consider it as a hit?
My solution also fails WA#5 and I don't understand why... any hints guys?