I've got WA 5 cause I checked that distance less than d only in case where Gnusmas is not on the border of the arc. So, if you have WA#5 be careful with case where Gnusmas is on the border of the arc of fire. i have got WA on test #5. Help me please. Thanks [code deleted] My first submit got WA#8, my second WA#9, my third got WA#10 of course. I am going so straight, so incrementally. Maybe author made tests in such an amazing increasing-difficulty way. Edited by moderator 03.12.2019 21:46 I was so stupid not to check the distance in case when arc of fire is zero degrees and gnusmas is on the line. const e = 1e-8; o = 50000; var i,n : longint; d,x1,y1,x2,y2,x,y : extended; procedure vvod; begin {assign(input,'1.txt'); reset(input);} read(d,x1,y1,x2,y2,n); x1 := x1*o; y1 := y1*o; x2 := x2*o; y2 := y2*o; end; function kill(x,y : extended) : boolean; begin kill := false; if ((x*y1-x1*y)*(x*y2-x2*y) < 0) and (sqrt(x*x+y*y)-d < e) then kill := true; if (abs(x*y1-x1*y) < e) and (abs(sqrt(x*x+y*y)+sqrt(sqr(x1-x)+sqr(y1-y))-sqrt(x1*x1+y1*y1)) < e) and (sqrt(x*x+y*y)-d < e) then kill := true; if (abs(x*y2-x2*y) < e) and (abs(sqrt(x*x+y*y)+sqrt(sqr(x2-x)+sqr(y2-y))-sqrt(x2*x2+y2*y2)) < e) and (sqrt(x*x+y*y)-d < e) then kill := true; end; procedure find; begin for i := 1 to n do begin read(x,y); if kill(x,y) then writeln('YES') else writeln('NO'); end; end; procedure vivod; begin {NOTHING} end; begin vvod; find; vivod; end. I do not Why but I have WA in #4 test to. I think i have WA when gnumus in 4 chetvert and avtomat can fire in 1 chetvert. how did you managed it? I have WA #4 too... I do not understand why I have WA on #4. Please, who get AC, give me some tests!!! Edited by author 24.03.2005 15:12 First my solution gives WA on such test : 5 1 0 0 1 1 -1 -1 My prog said that bibr kill gnusmus... Then I understood that my solution was wrong and wrote a new one. Now I check : 1) if we go from first vector (right frontier of fire) to vector of gnusmus and to left frontier in counterclockwise order. 2) if we go from second vector (left frontier of fire) to vector of gnusmus and to right frontier in clockwise order. If this two things are true then gnusmus is in the sector of fire => writeln('YES') That is all :-). Here is a code : [code deleted] Edited by moderator 03.12.2019 21:37 I think your solution won't work for the test: 1000 0 5 5 0 1 -1 1 It should be: YES [your x1*y2-x2*y1 = -25 which makes b1 = false.] I'm afraid this test is illegal The angle of fire arc in your test is 270 degrees, while the prob states it doesn't exceed 180 degress. Also recommend to try this one 5 0 -5 0 5 1 1 -1 ---input 2 -30000 -1 30000 0 8 -1 0 -1 1 0 1 1 1 1 0 1 -1 0 -1 -1 -1 ---output NO NO NO NO YES YES YES YES My output is same. But I have WA#1 (>_<) You can solve this problem in integers, without any angles. input#1: 30000 30000 29999 -29999 -30000 12 19999 19996 19999 19997 19999 19998 19999 19999 19999 20000 19999 20001 19999 20002 19999 20003 19998 19996 19998 19997 19998 19998 19998 19999 output#1: YES YES YES NO NO NO NO NO YES YES NO NO input#2: 30000 29999 30000 -30000 -29999 12 19999 19996 19999 19997 19999 19998 19999 19999 19999 20000 19999 20001 19999 20002 19999 20003 19998 19996 19998 19997 19998 19998 19998 19999 ouput#2: NO NO NO NO YES YES YES YES NO NO NO YES It's better to count angles like there --> arccos((x1*x2+y1*y2)/(rast(x1,y1)*rast(x2,y2))); Be carefull when cos is ~1. Good luck! This task can be solved without any operations with float values. Just "*", "+" and "compare" operations with Integers. const eps = 1e-9; var a1, b1, a2, b2, x, y, x1, y1, d, x2, y2: real; i, n: longint; Begin read(d, x1, y1, x2, y2); read(n); a1 := y1; b1 := -x1; a2 := y2; b2 := -x2; for i := 1 to n do begin read(x, y); if (abs(x1 - x2) < eps) and (abs(y1 - y2) < eps) then begin if (abs(a1 * x + b1 * y) < eps) and (x * x + y * y - eps <= d * d) and (abs(sqrt(x * x + y * y) + sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1)) - sqrt(x1 * x1 + y1 * y1)) < eps) then writeln('YES') else writeln('NO') end else if (a1 * x + b1 * y - eps <= 0) and (a2 * x + b2 * y + eps >= 0) and (x * x + y * y - eps <= d * d) then writeln('YES') else writeln('NO'); end; End. I solve this problem with type longint but it makes no difference... try this: 5 1 0 1 0 1 -1 0 corect is NO ...and it is more useful to use Longint instead of real to solve this problem. To compare distances use sqr of distances This test helped me: 1007 20 25 4 5 1 -16 -20 Answer : NO Edited by author 14.11.2012 21:28 This test helped me 5 0 1 0 1 1 0 1 correct answer: YES Give me 10 test please If you use Real types of variables, replace it by Extended. in 10th test x1=y1 and x2=y2 Hahaha I got WA#1 so many times just because i didn't notice that letters should be big)))) Here is my code : Const fi='input.txt'; fo='output.txt'; Var Range,a1,b1,a2,b2,x,y,x1,y1,x2,y2:real; n,i,j:integer; f,g:text; {------------------------------------------------------------------------} Begin Assign(f,fi); Reset(f); Assign(g,fo); Rewrite(g); Readln(f,Range,x1,y1,x2,y2); a1:=y1; a2:=y2; b1:=x1*(-1); b2:=x2*(-1); Readln(f,n); for i:=1 to n do Begin Readln(f,x,y); if (sqrt(x*x + y*y)<=Range) then if (x1<>x2) or (y1<>y2) then begin if ((x*a1+y*b1)*(x2*a1+y2*b1)>=0) and ((x*a2+y*b2)*(x1*a2+y1*b2)>=0) then Begin Writeln(g,'YES'); Continue; End; End else if (x1=x2) and (y1=y2) then if (x*a1+y*b1)=0 then Begin Writeln(g,'YES'); Continue; ENd; Writeln(g,'NO'); End; Close(f); Close(g); End. -Nothing- Edited by author 07.05.2009 17:45 Read FAQ! You must use standart Input/Output, not files. In statement: 1 <= |X1| , |Y1|, |X2|, |Y2| <= 30000 0 <= |Xi|, |Yi| <= 30000 In test 6 there is number with absolute value 30001. This number cannot cause overflow, but it is not good that the test does not correspond to the statement. The term "slightly wrong" sounds funny, especially in sport programming. What if I use hash that relies upon the fact that |X| <= 30000??? Edited by author 21.01.2009 01:53 It would be funny if you use hash in this problem. This is a geometrical problem, the only danger is to exceed int limit. 30001 was definitely not dangerous in this problem. But it hindered defensive programming style of debugging. The code removed after getting AC. Edited by author 25.01.2009 07:03 Test 3: arc of fire is 0 degrees. So arc of fire 0 degrees is pretty legal. But! I know many AC solutions that think that when arc of fire 0 degrees gnusmasses in _opposite_ direction will be killed. Test 100 1 0 1 0 1 -1 0 YES is wrong answer. I suggest to remove test with arc of fire 0 degrees and to write in statement that arc of fire strictly greater than 0. And add to timus problemset problem "Good Gnusmas – Dead Gnusmas. Version 2" without any limitations on size of arc of fire i.e. with limitation [0; 360) degrees. Arc greater than 180 degrees can be defined quite well because we know that first range is left and the second is right. Edited by author 19.01.2009 12:29 Yes, 0 degrees arc is legal in this problem. We added tests with the same idea as your test. Thank you. Edited by author 20.01.2009 03:29 In problem statement: "The arc of fire doesn’t exceed 180 degrees." "Сектор обстрела не превышает 180 градусов." "doesn't excees" is <=, not <. But test set doesn't contain test with arc of fire exactly 180 degrees. Please add test where the arc of fire is 180 degrees. Only solutions that use vectors (and assume that first bound of arc is right and the second is left) will survive it. Solutions that use lines (or do not distinguish left and right bounds) will get wa. Or if you do not want many authors get wa, change the statement: "The arc of fire is strictly less than 180 degrees." "Сектор обстрела строго меньше 180 градусов." Edited by author 11.01.2009 14:29 rus: "координаты точек соответственно на правой и левой границах обстрела." eng: "coordinates of the right and the left bounds of the arc of fire." It is problem from school championship so Russian text is original. Add please word "correspondingly" (or equivalent) in english text. It is _very_ important for some solutions of this problem. Also word "points" would be great because there is no such thing as "coordinates of the bounds". "расстояние от домика боба" -> "расстояние от домика Боба" and please synchronize пулемет Какашникова Kalashnikov machine gun (3rd letter :-)) is such a test legal: 5 1 1 1 1 2 1 1 -1 -1 if yes, then what shoud be the answer?.. here's in pascal: my c code: Edited by author 21.04.2008 03:06 because you use writeln('YES') and printf("YES") instead of printf("YES\n"); thank you, hahaha, i feel dumb..... Can anyone please say, what is this test? My program completed all tests from neighbour topics successfully... UPD: rewrote, got AC. Edited by author 05.04.2008 23:36 Edited by author 13.03.2007 10:53 |
|