#P7168. [eJOI 2020] Triangulation (Day1)

    ID: 8011 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>贪心2020交互题Special JudgeeJOI(欧洲)

[eJOI 2020] Triangulation (Day1)

Background

Instructions for use.


In this problem, (A,B)(A,B) represents a diagonal from AA to BB.

Define the eJ distance from vertex AA to vertex BB in a regular polygon as the maximum of: the number of edges when going from AA to BB clockwise, and the number of edges when going from AA to BB counterclockwise. Based on this definition, we can also define the eJ distance from a vertex AA to a diagonal BB of the polygon: it is the maximum of the number of edges from AA to one endpoint of diagonal BB (the closer endpoint) when going clockwise, and the number of edges when going counterclockwise.

For example, the eJ distance from point 00 to diagonal (0,5)(0,5) is 55. Going clockwise needs 55 edges, going counterclockwise needs 22 edges, so the answer is max{5,2}=5\max\{5,2\}=5.

Problem 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