Editorial for TLE '16 Contest 2 P4 - Harambe's Noble Quest
Submitting an official solution before solving the problem yourself is a bannable offence.
Authors:
,Subtask 1
We simply need to check if Harambe's path must intersect with the guard's sight. Either the single guard is covering the point or the guard covers a horizontal range of or a vertical range of .
Time complexity:
Subtask 2
The size of the grid is small, and thus the number of guards is low. Therefore, we can generate all possible paths to the origin, and count the number of guards that need to be taken out.
Time complexity: where .
Subtask 3
The number of guards is low. First, we should reflect all of the points across the and/or axis so that Harambe's original point contains non-negative coordinates. Let be the minimum number of guards that need to be eliminated in order to reach . Clearly, . The method counts the number of guards present in but not . The answer will be located at .
Time complexity:
Subtask 4
We need to optimize the solution for the previous subtask. Note that the only important event with any guard is when Harambe enters its range. Thus, we only need the top edge and the right edge of each guard's range (remember, the coordinate system is rotated so that Harambe's original point contains non-negative coordinates). We can use two separate arrays/grids to keep the count of top edges and right edges. Now, we can see that .
Time complexity:
Comments