← Back to topics
Topic

Task::It2

D
Diabolic
Now, 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.
h
halil
Problem 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.
D
Diabolic
Thanks for your tip. But again I got TLE. Look at my code.
h
halil
In 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.
D
Diabolic
I 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.
h
halil
i'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.
N
Nikola94
here'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 :)
D
Diabolic
Nikola94 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
Nikola94
@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