Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
why wa at 515ms?Source Problem Id:3029 User Id:qiqilrq Memory:188K Time:515MS Language:G++ Result:Wrong Answer * Source #include <stdio.h> #include <math.h> #include <algorithm> using namespace std; typedef struct { int id; double x, y, v, a; }guest; guest G[10]; bool cmp(guest g1,guest g2){ return g1.id<g2.id; } double gv; int n; double gettime() { double gdx=0, gdy=0; //guide position double curt=0, rett=0; for(int i=0;i<n;i++){ double vx=G[i].v*cos(G[i].a), vy=G[i].v*sin(G[i].a); double x0=G[i].x+curt*vx-gdx, y0=G[i].y+curt*vy-gdy; double aa=gv*gv-G[i].v*G[i].v, bb=x0*vx+y0*vy, cc=x0*x0+y0*y0; double ct=(bb+sqrt(bb*bb+aa*cc))/aa; //catch time curt+=ct; //current time gdx = G[i].x+vx*ct; gdy = G[i].y+vy*ct; //update guide position double dist=sqrt(gdx*gdx+gdy*gdy); double thistime=dist/G[i].v+curt; if(thistime>rett) rett=thistime; } return rett; } int main() { scanf("%d",&n); while(n>0){ int i,j=1; scanf("%lf",&gv); memset(G,0,10*sizeof(G[0])); for(i=0;i<n;i++) { scanf("%lf%lf%lf%lf",&G[i].x,&G[i].y,&G[i].v,&G[i].a); G[i].id=i; } double mt=gettime(); while(next_permutation(G,G+n, cmp)){ double t=gettime(); //cout<<j++<<": "<<t<<endl; if(t<mt) mt=t; } printf("%.0f\n",mt); scanf("%d",&n); } } /* 1 50.0 123.0 175.0 25.0 1.96 3 100.0 40 25 20 5.95 -185 195 6 2.35 30 -80 23 2.76 0 */ Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator