#P7168. [eJOI 2020] Triangulation (Day1)

[eJOI 2020] Triangulation (Day1)

Description

Given an NN-gon whose vertices are labeled clockwise as 0N10 \sim N-1, A has drawn n3n-3 diagonals. It is guaranteed that these n3n-3 diagonals have no extra intersections except at vertices.

Now A wants J to guess which diagonal has the smallest eJ distance to point 00, 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 nn, 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.
  • nn: the number of vertices of the polygon.
  • Suppose the answer diagonal is (a,b)(a,b). This function should return a×n+ba \times n+b.
  • If multiple diagonals are closest to point 00, you may return any one of them.

The solve function may call the following function multiple times:

int query(int x, int y)
  • x,yx,y: represent one query.
  • 0x,yn10 \le x,y \le n-1.
  • If (x,y)(x,y) exists, return 11, otherwise return 00.
7

Hint

Sample 1

The sample input format only contains one integer nn.

Function call Return value
solve(7)
query(0,3) 00
query(0,5) 11
query(1,5)
The solve function returns 1×7+5=121 \times7+5=12.
Correct.

Constraints

For 100%100\% of the testdata, 5n1005 \le n \le 100.

Assume qq is the number of queries you make for one test case. Let w=n×(n3)2w=\dfrac{n \times (n-3)}{2}. Your score for one test case is:

  • If the queries are invalid, the answer is wrong, or w<qw<q, you will get 0%0\% of the score.
  • If n<qwn<q \le w, you will get 10+60×wqwn%10+60 \times \dfrac{w-q}{w-n}\% of the score.
  • If qnq \le n, you will get 100%100\% of the score.

Thanks to

https://www.luogu.com.cn/user/174045
ing the checker & grader.

Notes

Translated from eJOI 2020 Day1 B Triangulation

Translated by ChatGPT 5