Editorial for VMSS '15 #3 - Jeffrey and Roads
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Note that since the roads extend forever, it is impossible for Jeffrey to go "around" the lines to the school. Thus Jeffrey has to cross a road if and only if he and the school are on different sides of the road.
Now how do we check if they're on different sides? Notice that the equation for the roads are conveniently given to use in form. If you remember from math class, having with coordinates means that you are ON the line. (thankfully, the question guarantees that does not happen) Now what happens if ? It means that the coordinate is on 1 side of the line. But what happens if ? It means that the coordinate is on the other side of the line. In fact, you can try it out on the Desmos calculator online to see for yourself.
Now with that info in mind, we can see Jeffrey and the school are on different sides of the road if one is negative and the other is positive.
Final Complexity:
Comments