Editorial for TLE '17 Contest 3 P1 - Willson and Territory


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: ZQFMGB12

According to the statement, any real point (x,y) is in Willson's territory if and only if |x-x_0| + |y-y_0| \le k, where k is the maximum value of |x_i-x_0| + |y_i-y_0| for some i \in [1,N].

Note that this definition is real Manhattan distance. Note that all points in an axis-aligned square that is rotated 45-degree have the same Manhattan distance from the center of that square. Therefore, we simply compute the area of that square, where k is the Manhattan distance from (x_0,y_0) to one vertex of the square.

Note that even if Willson takes "infinitely small" horizontal and vertical steps, he is not walking diagonally, due to the laws of mathematics. Therefore, we should not use any form of Euclidean distance.

Time Complexity: \mathcal{O}(N)


Comments

There are no comments at the moment.