Farthest Vertex
Limits: 2 sec., 512 MiB
This statement was translated automatically from Ukrainian.
This is an interactive problem (where your program interacts with the jury’s program via standard input and output).
A convex polygon with \(n\) vertices, numbered from \(1\) to \(n\) in counterclockwise order, lies on the Cartesian plane.
For a point \(A(x, y)\), we define the farthest vertex of the polygon as the one that is at the maximum distance from \(A\). If several vertices are at the maximum distance from \(A\), we consider the farthest one to be only the vertex with the smallest index.
You only know the number of vertices of the polygon \(n\), but the vertices themselves are unknown.
You can make at most \(100\) queries to the jury.
Your query must contain two integers \(x\) and \(y\). The jury’s response to the query is the index of the farthest vertex of the polygon for the point with coordinates \((x, y)\).
Your task is to find any point with integer coordinates for which vertex \(1\) will be the farthest.
Input
You are given an integer \(n\) — the number of vertices of the polygon.
After reading the number \(n\), the interaction between your program and the jury’s program begins, during which your program makes queries, and the jury’s program responds to them.
To make a query, output two integers \(x, y\) (\(-10^9 \le x, y \le 10^9\)) — the coordinates of the point.
In response to the query, the jury’s program will output the index of the farthest vertex of the polygon for the queried point.
If you receive 1 in response to your attempt, it means
you have found the required point. Immediately terminate your program
after this. Otherwise, your answer will not be judged.
If the attempt is invalid (for example, the maximum number of queries
is exceeded), the jury’s program will output -1 and
terminate the interaction. In this case, terminate your program to
receive the Wrong Answer verdict. If you do not do this,
you may get a Runtime Error verdict.
Make sure to call the flush method after outputting each
line. To do this, you can use:
fflush(stdout),cout << endlorcout.flush()inC++;System.out.flush()inJava;flush(output)inPascal;sys.stdout.flush()inPython;Console.Out.Flush()inC#.
Constraints
\(3 \le n \le 50\),
the coordinates of the polygon vertices do not exceed \(100\) in absolute value,
the polygon is strictly convex.
Notes
Below is an example of interaction for a quadrilateral with vertices at coordinates \((2, -1)\), \((5, 3)\), \((-1, 4)\), \((-2, -1)\).
| Input | Output | Description |
|---|---|---|
4 |
The polygon is a quadrilateral. | |
-3 -2 |
The participant makes a query for point \(A(-3, -2)\). | |
2 |
For point \(A\), the farthest vertex of the polygon has index \(2\). | |
2 -2 |
The participant makes a query for point \(B(2, -2)\). | |
3 |
For point \(B\), the farthest vertex of the polygon has index \(3\). | |
5 5 |
The participant makes a query for point \(C(5, 5)\). | |
4 |
For point \(C\), the farthest vertex of the polygon has index \(4\). | |
0 4 |
The participant makes a query for point \(D(0, 4)\). | |
1 |
For point \(D\), the farthest vertex of the polygon has index \(1\). |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|