#P13502. [OOI 2024] Draw Polygon Lines
[OOI 2024] Draw Polygon Lines
题目描述
This is an interactive problem.
You are given points on the plane. It is known that all are distinct and all are distinct.
Your task is to draw polygonal lines connecting these points.
A polygonal line is defined by a permutation of numbers from to . The polygonal line consists of segments, the first segment connects points and , the second segment connects points and , , the last segment connects points and . Note that segments may intersect.
The of a polygonal line is defined as the number of indices such that the angle is acute, i.e., strictly less than .
You need to solve four tasks:
- Find any polygonal line that has the maximum possible sharpness.
- Given an integer . Find any polygonal line whose sharpness is .
- Given an integer .
Answer queries, each specified by a single integer (). In the -th query, you need to construct a polygonal line that has sharpness exactly . - Given an integer .
For each from to , construct a polygonal line with sharpness exactly . Provide numbers $\text{hash}\left(p^{(c)}\right), \text{hash}\left(p^{(c+1)}\right), \ldots, \text{hash}\left(p^{(n-c)}\right)$ as the answer, where $hash(p) = \left( \sum\limits_{i=1}^{n} p_i b^{i-1} \right) \bmod m$ is the polynomial hash of permutation with parameters and .
Then answer queries, each specified by a single integer (). In the -th query, you need to provide the polygonal line . It will be checked that the sharpness of this polygonal line is exactly and its hash matches the previously provided value .
Note that queries will appear after receiving the hashes.
It is guaranteed, that under given constraints, the answers always exist.
Interaction Protocol
The first line contains two integers , (, ) --- the number of the task to be solved in this test and the test group number.
The second line contains a single integer () --- the number of points on the plane.
Each of the next lines contains two integers , () --- the coordinates of the points. It is guaranteed that all are distinct and all are distinct.
If , then the input ends here and you should output any permutation with the maximum possible sharpness. The interaction ends here.
If , then the next line contains a single integer ().
If , then the input ends here and you should output any permutation with sharpness . The interaction ends here.
If , your solution should output integers $\text{hash}\left(p^{(c)}\right), \text{hash}\left(p^{(c+1)}\right), \ldots, \text{hash}\left(p^{(n-c)}\right)$, where . Note that this should not be done if .
Further interaction occurs only if or .
The next line contains a single integer () --- the number of queries.
Then times, in each line, a query () appears. As a response, you should output a permutation on a separate line. The sharpness of this permutation should be exactly . If , the hash of this permutation should match the previously provided hash.
Since this is an interactive problem, after outputting each line, do not forget to output a newline character and flush the output buffer.
1 0
4
2 3
1 8
4 2
0 0
3 2 4 1
2 0
5
-2 0
-1 -1
0 1
2 -2
3 -3
2
5 4 3 1 2
3 0
6
0 0
1 1
2 2
3 -3
4 -2
5 -1
2
3
2
3
4
1 2 3 4 5 6
4 5 6 1 3 2
6 2 4 3 5 1
4 0
5
-2 -1
-1 1
1 6
0 -3
2 0
2
2
2
3
534735187 776162084
4 5 1 2 3
1 3 2 5 4
提示
Note
In all the figures, acute angles are denoted by two arcs, and non-acute angles are denoted by a single arc.
In the first example all angles are sharp, so the line has maximum sharpness .
In the second sample the sharpness equals to , it is .
In the third example the lines have sharpness , , .
In the forth example we build lines that have sharpness and . The lines have hashes equal to the ones provided earlier.
Scoring
The tests for this problem consist of twenty-one groups. Points for each group are given only if all tests of the group and all tests of the required groups are passed.
Group | Points | task | Additional constraints | Required Groups | Comment | ||
---|---|---|---|---|---|---|---|
0 | - | - | - | - | Examples. | ||
1 | 8 | 1 | |||||
2 | 6 | random points | |||||
3 | 5 | 2 | |||||
4 | 2 - 3 | ||||||
5 | 6 | - | 1 - 4 | ||||
6 | 17 | 2 | - | ||||
7 | 3 | ||||||
8 | 4 | random points | |||||
9 | |||||||
10 | |||||||
11 | 3 | ||||||
12 | |||||||
13 | 12 | ||||||
14 | - | 12 - 13 | |||||
15 | 2 | 7, 12 - 14 | |||||
16 | 6 | 4 | - | ||||
17 | 3 | random points | |||||
18 | |||||||
19 | 18 | ||||||
20 | - | 18 - 19 | |||||
21 | 2 | 16, 18 - 20 |
In the groups where it is indicated that the points are random, all coordinates of all points , are randomly generated with equal probability in the interval .