#P7168. [eJOI 2020] Triangulation (Day1)
[eJOI 2020] Triangulation (Day1)
Description
Given an -gon whose vertices are labeled clockwise as , A has drawn diagonals. It is guaranteed that these diagonals have no extra intersections except at vertices.
Now A wants J to guess which diagonal has the smallest eJ distance to point , and also report that distance.
J cannot know the answer by mind reading, so he can only ask A for some clues. A tells J the value of , and agrees that J may ask whether there is a diagonal between a pair of vertices, but J has a limit on the number of queries.
J still wants to AK eJOI, so this problem is handed to you.
Interaction rules
You need to include the header file triangulation.h.
int solve(int n)
- This function can only be called once.
- : the number of vertices of the polygon.
- Suppose the answer diagonal is . This function should return .
- If multiple diagonals are closest to point , you may return any one of them.
The solve function may call the following function multiple times:
int query(int x, int y)
- : represent one query.
- .
- If exists, return , otherwise return .
7
Hint
Sample 1
The sample input format only contains one integer .
| Function call | Return value |
|---|---|
solve(7) |
|
query(0,3) |
|
query(0,5) |
|
query(1,5) |
|
The solve function returns . |
|
| Correct. |
Constraints
For of the testdata, .
Assume is the number of queries you make for one test case. Let . Your score for one test case is:
- If the queries are invalid, the answer is wrong, or , you will get of the score.
- If , you will get of the score.
- If , you will get of the score.
Thanks to
Notes
Translated from eJOI 2020 Day1 B Triangulation。
Translated by ChatGPT 5
京公网安备 11011102002149号