Square or Rectangle?
Time limit1sMemory limit512 MB
A hidden axis-aligned square or rectangle covers at least 4% of a 100x100 grid; locate its edges with limited point queries and decide which shape it is.
- Level
Medium7 of 10
- Topics
- Geometry, Binary search, Implementation
- Solved
- No attempts yet
Problem
I can be a square, or a rectangle. Am I a square, or a rectangle?
Consider a grid of squares. Suppose there is either a square or a rectangle covering some grid squares, and each grid square is either completely inside or outside the shape, i.e. the boundary of the shape follows the grid lines. Two examples are shown below:
It is also guaranteed that the shape covers at least 4% of the total area of the grid. Your task is to determine if the shape is a square, or a rectangle. To do that, you are allowed to ask at most queries, each query allows you to find out if a certain grid square is inside the shape. The grid squares are identified by coordinates where .

