Triangulation: Statement
Triangulation: Statement
triangulation (English)
Triangulation
Statement
Anna drew a regular polygon with n vertices numbered from 0 to 𝑛 − 1 in clockwise order. Later
she triangulated it by drawing 𝑛 − 3 diagonals that do not intersect each other. Except possibly
where they touch at their endpoints. Diagonal is defined as straight lines between two different
vertices that aren’t sharing a side.
Anna wants to make a challenge for Jacob. Jacob does not know which diagonals are drawn at
all. He only knows the value of n, but can ask Anna multiple times about some pairs of vertices
and she will tell him whether a diagonal is present between those vertices. Jacob’s goal is to
find the closest (with distance defined as above) drawn diagonal from the vertex 0. You are
going to help him to achieve his goal by asking Anna a limited amount of questions.
Constraints
● 5 ≤ 𝑛 ≤ 100
triangulation Page 1 of 3
EJOI 2020 Day 1
triangulation (English)
Implementation Details
You should implement the following function in your submission:
int solve(int n)
● This function is called exactly once by the grader
● n: number of vertices in the polygon
● This function should return the diagonal between some vertices a and b as an integer
with value 𝑎 ⋅ 𝑛 + 𝑏
● If there are multiple diagonals with minimal distance you can return any of them
Sample interaction
Here is a sample input for grader and corresponding function calls. This input is shown in an
image above.
The only line in the input has one integer: n
Sample grader will print each query call to the stdout and you have to manually answer it with 1
or 0.
Sample Input Sample Calls
to grader Calls Returns Calls Returns
7 solve(7)
query(0, 3)
query returns 0
query(0, 5)
query returns 1
query(1, 5)
query returns 1
solve returns 1 ∙ 7 + 5 = 12
Correct!
triangulation Page 2 of 3
EJOI 2020 Day 1
triangulation (English)
Scoring
∙( )
Let’s denote q as the amount of question you used on a single test. Additionally, 𝑤 = .
● If you ask an invalid question or guess incorrectly you will receive 0% of points for a test
● If 𝑤 < 𝑞 you will receive 0% of points for a test
● If 𝑛 < 𝑞 ≤ 𝑤 you will receive 10 + 60 ∙ % of points for a test
● If 𝑞 ≤ 𝑛 you will receive 100% of points for a test
Subtasks
There is a single subtask and your score is the sum of individual test scores. But during the
contest you will only be able to see scores on half of the tests (worth 50 points). Other half of
the scores will be revealed after the contest. Your final score will be the best total score
among all submissions.
triangulation Page 3 of 3