## Editorial for Another Contest 5 Problem 4 - Tudor Interacts With Poop

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.

For the first subtask, we first note that there are lattice points inside the rectangle. Therefore, we can query all of them and find the corners of the rectangle directly as the top-left, top-right, bottom-left, and bottom-rightmost points.

For the second subtask, we cannot query close to the total number of lattice points. The bound of looks suspiciously like , but this is intended as a bait to trick people who automatically assume that every interactive problem is intended to be solved with binary search.

The intended solution for the second subtask is to start by querying all four corners of the rectangle. This is a good first step because intuitively the most obvious way of seeing if the corner is in the rectangle is by querying it directly. We'll focus exclusively on the origin. If the answer we get back is , then we know that the lower-left corner of the rectangle lies on the line . If we query , we know that the top-left corner lies on the line . If we could query any point on the plane, we would then query the intersection point of those two lines to get the distance of the left side of the rectangle to the line . We forcibly snap the -coordinate to zero and discretize the -coordinate if it doesn't lie on a lattice point. Repeating this process for all four sides, we only need eight queries.

To get full credit, we first realize that we don't need to query all four corners - querying any three corners automatically allows us to infer the line for the fourth corner. Finally, with three of these lines, identifying one corner as being on one of the lines automatically forces the other corners to be realized, so we only need to query for one side of the rectangle.