Show all threads Hide all threads Show all messages Hide all messages | If you have WA14...... | AleshinAndrei | 1215. Exactness of Projectile Hit | 9 Nov 2023 00:47 | 2 | Can someone proceed further on this topic? I have a WA14, and I literally can use only double in my program, so int64_t doesn't really help. | What is wrong in my solution (WA 16) | Paul | 1215. Exactness of Projectile Hit | 9 Feb 2020 03:12 | 3 | Edited by author 26.03.2009 23:03 Edited by author 26.03.2009 23:03 | Can someone give me some tests? | Danica Porobic | 1215. Exactness of Projectile Hit | 8 Jul 2014 06:09 | 9 | I got WA #4, but I think I got all special cases ok, so help please. I think all problem is in looking, where the center of projectile is situated(outside or inside)... I tryied to find the diameter with binary search and at each step we verify if it crosses the polygon. I used different approach, first I calculate if the center is inside, using dummy point ( point that is inside ), and then I calculate minimum distance to the from then center to the polygon, my code: [code deleted] Edited by moderator 13.02.2007 20:51 Here is a test for you: -1000000 1000000 4 0 -1000 600 0 0 1000 -1000 0 mine says: 2827012.911 yours: 2827013.265 little diference but... You can implement the binary search, it's easy... And then compare it with your solution to find the bug... I have the same solution and it gives the same answer to the offered test. It is mathematically proved that the algo is correct. Thus, the difference from right answer appears only because of computer limitations. It means we should try to guess the author's solution (according to which the tests were created) and throw away all other correct ones (this, for example). It's completely unfair. 3 0 8 0 2 2 0 4 0 6 2 6 4 4 6 2 6 0 4 [0.000] 0 0 8 0 2 2 0 4 0 6 2 6 4 4 6 2 6 0 4 [2.828] 0 0 4 1 1 -1 1 -1 -1 1 -1 [0.000] -1000000 -1000000 3 999999 1000000 1000000 999999 1000000 1000000 [5656852.835] 2 0 3 4 0 3 3 0 3 [2.400] try this test.... 0 0 3 1 0 3 0 2 3 -> 2.000 Why do you write such tests? Coordinates must be in range [-2000, 2000] Edited by author 08.07.2014 06:09 | what's wrong with my program? | YSYMYTH | 1215. Exactness of Projectile Hit | 27 Feb 2013 17:16 | 1 | help plz... #include<cstdio> #include<cmath> #include<algorithm> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) struct Point{ int x,y; Point(int x=0,int y=0):x(x),y(y){} void Read(){ scanf("%d %d",&x,&y);} int operator ^ (Point o){ return x*o.y-o.x*y;} int operator * (Point o){ return x*o.x+y*o.y;} Point operator - (Point o){ return Point(x-o.x,y-o.y);} }P[10000],buf; double dis(double a,double b,double c,Point P){ return (a*(double)P.x+b*(double)P.y+c)/(sqrt(a*a+b*b)); } double dis(Point p,Point q){ return sqrt((double)((q-p)*(q-p))); } int n; int main(){ buf.Read(); scanf("%d",&n); rep(i,n) P[i].Read(); P[n]=P[0]; P[n+1]=P[1];
bool inCon=1; rep(i,n) { if( ((P[i+1]-P[i]) ^ (buf-P[i])) * ((P[i+2]-P[i+1]) ^ (buf-P[i+1])) <0 ){ inCon=0; break; } } if(inCon) {printf("0.000"); return 0;}
double ans=19970815.0; rep(i,n){ Point N(P[i+1].y-P[i].y,P[i].x-P[i+1].x); // fa xiang double c=-(N*P[i]); double d= ((P[i]-P[i+1])*(buf-P[i+1])) * ((P[i+1]-P[i])*(buf-P[i])) >0 ?dis(N.x,N.y,c,buf) : min(dis(P[i],buf),dis(P[i+1],buf)); if(ans>d) ans=d; }
printf("%.03lf",ans*2); } | If you have WA#21 then try this test: | ErOPb|4[USU] | 1215. Exactness of Projectile Hit | 30 Oct 2011 12:23 | 3 | 0 0 3 100 1 0 2 -100 1 Correct answere is 2.000 Thank you! It helped me to get AC. | If you have WA7 | Lebedev_Nicolay[Ivanovo SPU] | 1215. Exactness of Projectile Hit | 2 Sep 2011 17:54 | 3 | If you have WA7 then check up: the point is inside the polygon or not. Thank you very much! Your hint helped me to get AC Edited by author 23.02.2010 20:43 | SERUS EDDY | Micheal Jackson | 1215. Exactness of Projectile Hit | 24 Jan 2011 17:48 | 1 | Ma prietenule! Ce mai faci? Vrei sa ma iubesti? | why wa2?I have tried many tests,and output the right answer,but WA2 | uuu | 1215. Exactness of Projectile Hit | 1 Sep 2010 20:20 | 1 | var i,j,k,n,m,tot:longint; ans,x1,y1,x2,y2,d1,d2,d3,x,y,angle1,angle2,t,p1,p2:double; function min(xx,yy:double):double; begin if xx>yy then exit(yy); exit(xx); end; begin {assign(input,'1215.in');reset(input);} read(x,y,n); read(x1,y1); p1:=x1; p2:=y1; d1:=sqrt(sqr(x-x1)+sqr(y-y1)); ans:=999999999; tot:=0; for i:=2 to n do begin read(x2,y2); if (x1<x)and(x2>=x)and((y1<y)or(y2<y)) then inc(tot); d2:=sqrt(sqr(x-x2)+sqr(y-y2)); d3:=sqrt(sqr(x1-x2)+sqr(y1-y2)); angle1:=(d2*d2+d3*d3-d1*d1)/(2*d2*d3); angle2:=(d1*d1+d3*d3-d2*d2)/(2*d1*d3); if (angle1>=0)and(angle2>=0) then begin if x1=x2 then t:=abs(x1-x) else t:=((y1-y2)/(x1-x2)*x-y+y1+(y2-y1)/(x1-x2)*x1)/(sqrt(sqr((y1-y2)/(x1-x2))+1)); t:=abs(t); ans:=min(ans,t); end else begin t:=min(d1,d2); ans:=min(ans,t); end; d1:=d2; x1:=x2; y1:=y2; end; x2:=p1; y2:=p2; if (x1<x)and(x2>=x)and((y1<y)or(y2<y)) then inc(tot); d2:=sqrt(sqr(x-x2)+sqr(y-y2)); d3:=sqrt(sqr(x1-x2)+sqr(y1-y2)); angle1:=(d2*d2+d3*d3-d1*d1)/(2*d2*d3); angle2:=(d1*d1+d3*d3-d2*d2)/(2*d1*d3); if (angle1>=0)and(angle2>=0) then begin if x1=x2 then t:=abs(x1-x) else t:=((y1-y2)/(x1-x2)*x-y+y1+(y2-y1)/(x1-x2)*x1)/(sqrt(sqr((y1-y2)/(x1-x2))+1)); t:=abs(t); ans:=min(ans,t); end else begin t:=min(d1,d2); ans:=min(ans,t); end; if odd(tot) then ans:=0; writeln(ans*2:0:3); end. | solution | Macarie programatorul in actiune | 1215. Exactness of Projectile Hit | 16 May 2010 09:59 | 5 | solution Macarie programatorul in actiune 1 Aug 2004 04:17 easy simple binary search for r... Just a case with the point in target. yes it was very easy to implemet but got almost 0.015 seconds to run... Edited by author 07.07.2005 19:51 Pure math solution is also pretty clear and easy (if you know algebra well). | Can it hit the target? | Pier Paolo Guillen Hernandez | 1215. Exactness of Projectile Hit | 6 May 2009 22:25 | 4 | Can the projectile hit the target? If so, is the answer 0? Yeah, you are right at all! Thanks you very much, guys! It is very useful notice! I've got AC using this notice! Shouldn't an answer be negative in this case? ;-) | wa in test#20 | panyong0202 | 1215. Exactness of Projectile Hit | 1 Apr 2009 15:08 | 2 | I also have wa#20 Where's mistake? But you've solved it, maybe you'll help me? var i,n:integer; cx,cy,x1,y1,x2,y2,x3,y3,x4,y4:integer; x,y:array[1..102]of integer; h,min,zn,ras1,ras2:real; f:boolean; begin read(cx);read(cy);readln(n); for i:=1 to n do readln(x[i],y[i]); x[n+1]:=x[1];y[n+1]:=y[1]; f:=true; zn:=0; for i:=1 to n do begin x1:=x[i]-cx;y1:=y[i]-cy; x2:=x[i+1]-cx;y2:=y[i+1]-cy; if (zn=0)then begin zn:=x1*y2-x2*y1; if (zn=0)then begin if ((x[i]<=cx)and(cx<=x[i+1]))or((x[i]>=cx)and(cx>=x[i+1]))then f:=true else f:=false; break;break;break; end; end else begin if (zn*(x1*y2-x2*y1)<0)then begin f:=false; break;break;break; end; end; end; if (f=true)then write('0.000') else begin min:=0; f:=false; for i:=1 to n do begin x1:=cx-x[i];y1:=cy-y[i];x2:=x[i+1]-x[i];y2:=y[i+1]-y[i];x3:=cx-x[i+1];y3:=cy-y[i+1];x4:=x[i]-x[i+1];y4:=y[i]-y[i+1]; if (x1*x2+y1*y2>0)and(x3*x4+y3*y4>0)then begin x1:=x[i]-cx;y1:=y[i]-cy;x2:=x[i+1]-cx;y2:=y[i+1]-cy; h:=(abs(x1*y2-x2*y1))/(sqrt(sqr(x[i+1]-x[i])+sqr(y[i+1]-y[i]))); end else h:=0; ras1:=sqrt(sqr(cx-x[i])+sqr(cy-y[i]));ras2:=sqrt(sqr(cx-x[i+1])+sqr(cy-y[i+1])); if (ras2<ras1)then ras1:=ras2; if (ras1<h)or(h=0)then h:=ras1; if (f=false)or(h<min)then begin min:=h; f:=true; end; end; write((2*min):0:3); end; end. | I have WA 16 "1215"! Precision? Algo? Hm... A'm amazing! | Andriy Buday [Lviv NU] | 1215. Exactness of Projectile Hit | 22 Sep 2008 19:55 | 5 | Look here. It's my code! Pz. find good tests for it! //1215_SB #include <iostream> #include <cmath> using namespace std; #define eps 0.000001 struct Point{ // ....}; inline double triangle_S(Point& pa, Point& pb, Point& pc){ //calculates square of truiangle... } inline long double min_dist_to_line(Point& A, Point& B, Point& C) { //here are a big and fat bug :) Point S; S.x = (B.x + A.x)/2.0; S.y = (B.y + A.y)/2.0; long double res = 0.0; long double a = C.dist(A); long double b = C.dist(B); long double d = A.dist(B); long double s = C.dist(S); if((s < a)&&(s < b)) { res = sqrt(a*a - ((a*a - b*b + d*d)/(2.0*d))*((a*a - b*b + d*d)/(2.0*d))); } else res = (a > b) ? b : a; return res; } Point a[103]; int main() { int n, i; //getting the data double S_of_target = 0.0; for (int i = 1; i <= n; i++) { S_of_target += triangle_S(Dolly, a[i], a[i+1]); } double S_of_target_from_Center = 0.0; for (int i = 1; i <= n; i++) { S_of_target_from_Center += triangle_S(Center, a[i], a[i+1]); } if (fabs(S_of_target_from_Center - S_of_target) < eps) { printf("0.000\n"); return 0; } long double min = 9999999999999999999999.9; for(i = 1; i <= n; i++) { ////////////////////////////////// double d_t_l = min_dist_to_line(a[i], a[i+1], Center); if(min - d_t_l > eps) { min = d_t_l; } ///////////////////// } printf("%.3lf\n", 2.0*min);
return 0; } Edited by author 23.02.2007 15:37 try this test: -1000000 -1000000 3 0 1000000 -1000000 1000000 1000000 999531 [3999999.890] your program output: 4000000.000 (fell the difference :)) I think your bug in min_dist_to_line function in criterion of existing normal line to section [A, B] from point C on plane. You may change it on criterion of existing obtuse angle in triangle. And you will get AC. Good luck. I think that there are no difference between: yours: res = sqrt(a + b + d) / d * sqrt(-a + b + d) * sqrt(a - b + d) * sqrt(a + b - d); res /= 2.0; and my: res = sqrt(a * a - ((a * a - b * b + d * d) / (2.0 * d)) * ((a * a - b * b + d * d) / (2.0 * d))); Because I got AC with my variant. The only one problem was in this: I wrote this condition if((s < a) && (s < b)) you wrote: if ((s1 > 0) && (s2 > 0)) s1 and s2 means: s1 = ( a * a - b * b + d * d); s2 = (-a * a + b * b + d * d); So I just missed that the triangle can be not able to be calculated with this function! Thank you very much! try this test: -1000000 -1000000 3 0 1000000 -1000000 1000000 1000000 999531 [3999999.890] your program output: 4000000.000 (fell the difference :)) I think your bug in min_dist_to_line function in criterion of existing normal line to section [A, B] from point C on plane. You may change it on criterion of existing obtuse angle in triangle. And you will get AC. Good luck. by the way, this test is't correct.. and my programm solve it.. i have wa16( can anybody help me? Edited by author 21.09.2008 22:36 Edited by author 21.09.2008 22:38i've solved it. i think 16th test is like this: 1999 0 3 2000 0 -2000 1 0 2000 | Корректность тетстов. | Tchurov Tim | 1215. Exactness of Projectile Hit | 6 Sep 2008 16:23 | 4 | Вам не кажется, что у задачи какие кривые тесты? Мое решение заработало, только после того как я перевел вычисления в действительные числа (такие как скалярное и косое произведения), что вообще-то смешно. При этом позицианируется, что ВСЕ координаты - целые числа в отрезке [-2000,2000] (среди участников дискуссий проверочные тесты были для больших ограничений - это подтверждает, что с тестами что-то не так).
Among tests there are definitely tests in which two points coincide (I've solved this problem very long time ago and don't remember exact numbers of the tests, but remember that there ARE such tests). If you are using C, you might get OK instead of CRASH with real numbers. UPD: test #9, maybe others after it. P.P.S. But coinciding points are not prohibited by problem statement... Edited by author 03.09.2008 02:46 2 ADMINS: Please, pay attention to this post... You are right. There were coinciding vertices in test#9. It is fixed now. | I have WA 21. Can you help me? | Denis | 1215. Exactness of Projectile Hit | 8 Aug 2008 20:51 | 4 | Here's my code: #include <fstream> #include <stdio.h> #include <cmath> using namespace std; long double eps = 1e-5; double min (double a, double b) { if (b-a > eps) { return a; } return b; } int n; double x, y; double arr[1110][2] = {0}; double dist (double x1, double y1, double x2, double y2) { double sc1, sc2; double d1, d2, d; d1 = (x-x1)*(x-x1) + (y-y1)*(y-y1); d1 = sqrt (d1); d2 = (x-x2)*(x-x2) + (y-y2)*(y-y2); d2 = sqrt (d2); sc1 = (x-x1)*(x2-x1) + (y-y1)*(y2-y1); sc2 = (x-x2)*(x1-x2) + (y-y2)*(y1-y2); d = min (d1, d2); if (sc1 >= 0 && sc2 >= 0) { d1 = (x-x1)*(y2-y1) - (x2-x1)*(y-y1); d2 = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1); d2 = sqrt (d2); if (d2 > eps) { d1 /= d2; d1 = fabs (d1); if (d1 != 0) { d = min (d, d1); } } } return d; } int main () { //freopen ("a.in", "r", stdin); //freopen ("a.out", "w", stdout); int i, j; scanf ("%lf%lf%d", &x, &y, &n); for (i = 0; i < n; ++i) { scanf ("%lf%lf", &arr[i][0], &arr[i][1]); } double d = dist (arr[0][0], arr[0][1], arr[1][0], arr[1][1]); double d1; double angle = 0; double sn; double x1 = arr[0][0], x2 = arr[1][0], y1 = arr[0][1], y2 = arr[1][1]; sn = (x1-x)*(y2-y) - (x2-x)*(y1-y); d1 = sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y))*sqrt((x2-x)*(x2-x)+(y2-y)*(y2-y)); sn /= d1; angle += asin (sn); for (i = 1; i < n; ++i) { j = (i+1)%n; x1 = arr[i][0], x2 = arr[j][0], y1 = arr[i][1], y2 = arr[j][1]; sn = (x1-x)*(y2-y) - (x2-x)*(y1-y); d1 = sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y))*sqrt((x2-x)*(x2-x)+(y2-y)*(y2-y)); sn /= d1; angle += asin (sn); d1 = dist (arr[i][0], arr[i][1], arr[j][0], arr[j][1]); d = min (d, d1); } if (angle > 2.0) { printf ("0.000\n"); return 0; } d *= 2.0; printf ("%.3lf\n", d); return 0; } I have same problem. I got WA21 please help me # include <iostream.h> # include <stdio.h> # include <math.h> int main () { int i,n,h1,h2,h3; double s1=0,s2=0,x,y,otv,min; double dx[100],dy[100]; cin>>x>>y>>n; cin>>dx[0]>>dy[0]>>dx[1]>>dy[1]; s2=fabs(0.5*((dx[0]-x)*(dy[1]-y)-(dx[1]-x)*(dy[0]-y))); for(i=2;i<n;i++) { cin>>dx[i]>>dy[i]; s1+=fabs(0.5*((dx[i-1]-dx[0])*(dy[i]-dy[0])-(dx[i]-dx[0])*(dy[i-1]-dy[0]))); s2+=fabs(0.5*((dx[i-1]-x)*(dy[i]-y)-(dx[i]-x)*(dy[i-1]-y))); } s2+=fabs(0.5*((dx[0]-x)*(dy[n-1]-y)-(dx[n-1]-x)*(dy[0]-y))); if(fabs(s1-s2)<=0.000000001) { cout<<"0.000"; return 0; } else { min=sqrt((x-dx[0])*(x-dx[0])+(y-dy[0])*(y-dy[0])); h1=n-1;h2=0;h3=1; for(i=1;i<n;i++) { if(min>sqrt((x-dx[i])*(x-dx[i])+(y-dy[i])*(y-dy[i]))) { min=sqrt((x-dx[i])*(x-dx[i])+(y-dy[i])*(y-dy[i])); h2=i;h1=i-1;h3=(i+1)%n; } } otv=min; double d1=fabs((x-dx[h2])*(dy[h1]-dy[h2])-(y-dy[h2])*(dx[h1]-dx[h2]))/sqrt((dy[h1]-dy[h2])*(dy[h1]-dy[h2])+(dx[h1]-dx[h2])*(dx[h1]-dx[h2])); double d2=fabs((x-dx[h2])*(dy[h3]-dy[h2])-(y-dy[h2])*(dx[h3]-dx[h2]))/sqrt((dy[h3]-dy[h2])*(dy[h3]-dy[h2])+(dx[h3]-dx[h2])*(dx[h3]-dx[h2])); if(((x-dx[h2])*(dx[h1]-dx[h2])+(y-dy[h2])*(dy[h1]-dy[h2]))+0.000000001>=0) if(d1<otv+0.00000001) otv=d1; if(((x-dx[h2])*(dx[h3]-dx[h2])+(y-dy[h2])*(dy[h3]-dy[h2]))+0.000000001>=0) if(d2<otv+0.00000001) otv=d2; printf("%.3lf",(2*otv)); } return 0; } I also got WA#21 and don't know where is mistake in my code: program z1215; {$APPTYPE CONSOLE} uses SysUtils; var px,py,n,i,nom,nom1,nom2:integer; a:array [1..100,1..2] of integer; r1,ab,bc,ac:real; m:boolean; function dlina (ab,bc,ac:real):real; var p:real; begin if bc*bc+ab*ab-ac*ac<=0 then begin dlina :=bc; exit; end; if ac*ac+ab*ab-ab*ab<=0 then begin dlina:= ac; exit; end; p:=(ab+bc+ac)/2; dlina:=(2*sqrt(p*(p-ac)*(p-bc)*(p-ab)))/ab; end; function func (x1,y1,x2,y2,xt1,yt1,xt2,yt2:integer):boolean; var k1,k2,b1,b2,xp,yp:real; k:integer; m:boolean; begin m:=false; k:=0; if (x2-x1)<>0 then begin k1:= (y2-y1)/(x2-x1); b1:= y1-k1*x1; end else k:=1; if (xt2-xt1)<>0 then begin k2:= (yt2-yt1)/(xt2-xt1); b2:= yt1-k2*xt1; end else k:=k+10; if (k1<>k2) and (k=0) then xp:= (b2-b1)/(k1-k2); if k=1 then xp:=x1; if ((k1<>k2) or (k=1)) and ((xp-xt1)*(xp-xt2)>=0) and ((k=0) or (k=1)) then m:= true; if (k1=k2) and (k=0) then m:= true; if k=11 then m:=true; if k=10 then begin yp:=k1*xt1+b1; if (yp-yt1)*(yp-yt2)>=0 then m:=true; end; func:=m; end; begin readln (px,py,n); for i:=1 to n do readln (a[i,1],a[i,2]); for i:=1 to n-2 do begin m:=func(a[i,1],a[i,2],a[i+1,1],a[i+1,2],a[i+2,1],a[i+2,2],px,py); if not m then break; end; if m then m:=func(a[n-1,1],a[n-1,2],a[n,1],a[n,2],a[1,1],a[1,2],px,py); if m then m:=func(a[n,1],a[n,2],a[1,1],a[1,2],a[2,1],a[2,2],px,py); if m then begin writeln ('0.000'); exit; end; r1:=sqrt(sqr(px-a[1,1])+sqr(py-a[1,2])); nom:=1; for i:=2 to n do if sqrt(sqr(px-a[i,1])+sqr(py-a[i,2]))<r1 then begin r1:=sqrt(sqr(px-a[i,1])+sqr(py-a[i,2])); nom:=i; end; if nom>1 then nom1:=nom-1 else nom1:=n; if nom<n then nom2:=nom+1 else nom2:=1; if sqrt(sqr(px-a[nom2,1])+sqr(py-a[nom2,2]))<sqrt(sqr(px-a[nom1,1])+sqr(py-a[nom1,2])) then nom1:=nom2; ab:=sqrt(sqr(a[nom,1]-a[nom1,1])+sqr (a[nom,2]-a[nom1,2])); bc:=sqrt(sqr(a[nom,1]-px)+sqr (a[nom,2]-py)); ac:=sqrt(sqr(a[nom1,1]-px)+sqr (a[nom1,2]-py)); writeln ( 2*dlina(ab,bc,ac):1:3); end. I find the mistake, I have AC now. Try this test: 0 0 3 100 1 0 2 -100 1 Correct answere is 2.000 | What I shall output if? | Mihran Hovsepyan {1 kurs of <RAU>} | 1215. Exactness of Projectile Hit | 12 Jun 2008 23:21 | 1 | IF R=0.000999999999 I think (2*R).3f =(0.00199999).3f=0.001 (MY Solution gives 0.001) BUT 2*(R.3f)=2*(0.0009999999.3f)=0.000 Edited by author 24.06.2008 15:14 | Help please... WA4... | Neo Nomaly | 1215. Exactness of Projectile Hit | 20 Feb 2008 18:59 | 4 | {$APPTYPE CONSOLE} {$n+} uses SysUtils; type tpoint=record x,y:{longint} extended; end; const maxn=200; var a:array[1..maxn] of tpoint; n:longint; min:extended; f:tpoint; procedure init; var i:longint; begin assign(input,'input.txt'); reset(input); assign(output,'output.txt'); rewrite(output); readln(f.x,f.y,n); for i:=1 to n do readln(a[i].x,a[i].y); inc(n); a[n+1].x:=a[1].x; a[n+1].y:=a[1].y; min:=maxlongint; end; function scalmul(p1,p2,p3,p4:tpoint):extended; begin scalmul:=(p2.x-p1.x)*(p4.x-p3.x)+(p2.y-p1.y)*(p4.y-p3.y); end; function rast(p1,p2:tpoint):extended; begin rast:=sqrt(sqr(p2.x-p1.x)+sqr(p2.y-p1.y)); end; function vecmul(p1,p2,p3,p4:tpoint):extended; begin vecmul:=(p2.x-p1.x)*(p4.y-p3.y)-(p2.y-p1.y)*(p4.x-p3.x); end; function prov:boolean; var i,j:longint; b:boolean; begin b:=true; for i:=1 to n-1 do if vecmul(a[i],f,a[i],a[i+1])>=0 then begin if b then b:=false; end; prov:=b; end; procedure solve; var i,j,im,l,r:longint; h:extended; begin if prov then begin writeln(0.0:0:3); halt; end; dec(n); for i:=1 to n do if rast(f,a[i])<min then begin min:=rast(f,a[i]); im:=i; end; l:=i-1; r:=i+1; if l<1 then inc(l,n); if r>n then dec(r,n); if (scalmul(a[l],f,a[l],a[im])>0) and (scalmul(a[im],f,a[im],a[l])>0) then begin h:=vecmul(f,a[im],f,a[l])/rast(a[im],a[l]); if min>h then min:=h; end; if (scalmul(a[r],f,a[r],a[im])>0) and (scalmul(a[im],f,a[im],a[r])>0) then begin h:=vecmul(f,a[im],f,a[r])/rast(a[im],a[r]); if min>h then min:=h; end; end; procedure done; begin writeln(abs(min*2):0:3); end; begin init; solve; done; end. in 4 test answer 0.000 (100%)(так что думай) yeah I have writtln 0 and I got WA at #4test then i wrote 0.000 and got AC I didn't understand where was the mistake in the code... if you have true code can you send me it on my e-mail, please? my e-mail : liwang@mail.ru I can send you any code if I have solved it. don't look to my account. just send me the number that you want. if I have it I will send you in return for this problem. thank you | Help Please. Crash on Test 9. | Golovnev Sasha | 1215. Exactness of Projectile Hit | 28 Nov 2007 02:40 | 3 | Why I have "Crash (FLT_INVALID_OPERATION)"? I not use division by zero and I use sqrt(x) only where x>=0. Sorry for bad English. Edited by author 23.02.2005 21:35 Edited by author 23.02.2005 21:35 I had the same problem, but I solved it. Your problem is when the point lies on one of the sides of the polygon. You have division by zero. | How to output double diameter and what's wrong with 4(+) | SPIRiT | 1215. Exactness of Projectile Hit | 1 Sep 2006 16:22 | 1 | I have 3 questions: 1) What does it mean "inside the polygon". If the target point lies on one of the edges is it inside the polygon. 2) I just found the distances from each edge to the target point and chose the minimal one. If the the target was inside the polygon, I output 0.000. Is that correct 3) I find the minimal distance, after that I multiply it on 2. How to output: should I use any round functions. I just used fprintf(stdout,"%.3f",res), where res is the diameter found and got WA at 4. If I tried to round it up to the third digit, I had WA at 2. What's the correct approach? | Why the answer on sample is 2.000? | The Punisher | 1215. Exactness of Projectile Hit | 22 Aug 2006 14:45 | 2 | Why the answer on sample test is 2.000? I think it should be 1.000. Could anybody explain me? Thanks. The problem asks for the "minimal diameter of a projectile" not the radius. | Help WA5? | Neo Nomaly | 1215. Exactness of Projectile Hit | 6 Feb 2006 15:37 | 1 | Can you write 5 test, please? |
|
|