DNow, again I got all wrong results, and two TLE. What's the problem. Here is the code:
http://www.z-trening.com/new/www/html/submit.php?submit=7100044448&subm_code=1
Thanks in advance.
hProblem je u deljenju sa 0, tj u
k=(y2[1]-y1[1])/(x2[1]-x1[1])
Preporucujem da pogledaš
http://www.dms.org.rs/competitions/informatics/problems/pripreme_Nis_2009/Geometrijski algoritmi [teorija] B.pdf
Pozdrav.
DThanks for your tip. But again I got TLE. Look at my code.
hIn case of x2[0] = x1[0] then there is div with 0, and in case of x2[1] = x1[1] same case... And i also think that your idea is bad becouse you didn't understood the task correctly, and you should start over with another idea.
DI think I understood the task correctly. Since, the tasks says that the spaceship has infinite small width and length, than it is line. The same is about asteroids. To crash each other the lines must intersect. That's what I do.
hi'm sure that you understood problem, but your solution says differently. try this:
0 0 1 1
1
3 0 0 3
i don't use C but i think that your solution gives result 1, but it should be 0.
Nhere's a hint: use linear programming to find out are the end points of asteroid's path on the different side of the straight that comprehends the ship's path. use it twice, first with regard to the ship's path and then to the asteroid's path. that's how you find out do those 2 segments intersect. i hope i helped :)
DNikola94 I don't know understand very much what you are saying to me.
hallil it should be 1 since the lines are y=x and y=-x+3 and they intersect in the point (1.5,1.5) so it should be 1. I don't know whats the problem.
N@diabolic:
lines intersect in the point (1.5 , 1.5) not segments. draw a segment on a piece of paper which end points have the coordinates (0,0) and (1,1). then draw a segment which end points have coordinates (3,0) and (0,3). you will see it yourself that those 2 segments don't intersect