#K52037. Treasure Hunt in a Grid
Treasure Hunt in a Grid
Treasure Hunt in a Grid
You are given an n × n grid with a hidden treasure placed in one of its cells. The rows and columns are numbered from 1 to n. Your task is to find the treasure's coordinates using a simulated query function.
A query is defined as follows: given a rectangular region specified by its top‐left corner (x1, y1) and bottom‐right corner (x2, y2), the query function returns "Yes" if the treasure is located inside or on the boundary of that rectangle, and "No" otherwise.
You are expected to implement a strategy based on binary search along the rows and the columns to identify the exact location of the treasure with as few queries as possible. In this problem, you will simulate the query function using the provided treasure coordinates.
Note: Although the problem describes the querying process, the input will include the actual treasure coordinates for simulation purposes. Your program should read from standard input and output the correct treasure coordinates to standard output.
inputFormat
The input consists of a single test case in the following format:
n r c
Where:
n
is an integer representing the size of the grid (n × n).r
andc
are integers representing the row and column of the hidden treasure, respectively.
All indices are 1-based.
outputFormat
Output the coordinates of the treasure as two space-separated integers:
r c
Where r
is the row number and c
is the column number of the treasure.
5
3 4
3 4