#P13502. [OOI 2024] Draw Polygon Lines

    ID: 14505 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2024交互题Special JudgeMoscow Olympiad

[OOI 2024] Draw Polygon Lines

题目描述

This is an interactive problem.

You are given nn points Ai=(xi,yi)A_i = (x_i, y_i) on the plane. It is known that all xix_i are distinct and all yiy_i are distinct.

Your task is to draw polygonal lines connecting these nn points.

A polygonal line is defined by a permutation p1,p2,,pnp_1, p_2, \ldots, p_n of numbers from 11 to nn. The polygonal line consists of n1n-1 segments, the first segment connects points Ap1A_{p_1} and Ap2A_{p_2}, the second segment connects points Ap2A_{p_2} and Ap3A_{p_3}, \ldots, the last segment connects points Apn1A_{p_{n-1}} and ApnA_{p_n}. Note that segments may intersect.

The sharpness\textit{sharpness} of a polygonal line is defined as the number of indices 2in12 \leq i \leq n - 1 such that the angle Api1ApiApi+1\angle A_{p_{i-1}} A_{p_i} A_{p_{i+1}} is acute, i.e., strictly less than 9090^{\circ}.

You need to solve four tasks:

  • Find any polygonal line that has the maximum possible sharpness.
  • Given an integer cc. Find any polygonal line whose sharpness is c\leq c.
  • Given an integer cc.
    Answer qq queries, each specified by a single integer kik_i (ckincc \leq k_i \leq n - c). In the ii-th query, you need to construct a polygonal line that has sharpness exactly kik_i.
  • Given an integer cc.
    For each kk from cc to ncn - c, construct a polygonal line p(k)p^{(k)} with sharpness exactly kk. Provide n2c+1n - 2c + 1 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 pp with parameters b=106+3b = 10^6 + 3 and m=109+7m = 10^9 + 7.
    Then answer qq queries, each specified by a single integer kik_i (ckincc \leq k_i \leq n - c). In the ii-th query, you need to provide the polygonal line p(ki)p^{(k_i)}. It will be checked that the sharpness of this polygonal line is exactly kik_i and its hash matches the previously provided value hash(p(ki))\text{hash}\left(p^{(k_i)}\right).
    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 task\text{task}, group\text{group} (1task41 \leq \text{task} \leq 4, 0group210 \leq \text{group} \leq 21) --- the number of the task to be solved in this test and the test group number.

The second line contains a single integer nn (3n800003 \leq n \leq 80\,000) --- the number of points on the plane.

Each of the next nn lines contains two integers xix_i, yiy_i (xi,yi109|x_i|, |y_i| \leq 10^9) --- the coordinates of the points. It is guaranteed that all xix_i are distinct and all yiy_i are distinct.

If task=1\text{task} = 1, then the input ends here and you should output any permutation with the maximum possible sharpness. The interaction ends here.

If task1\text{task} \neq 1, then the next line contains a single integer cc (2cn22 \leq c \leq \frac{n}{2}).

If task=2\text{task} = 2, then the input ends here and you should output any permutation with sharpness c\leq c. The interaction ends here.

If task=4\text{task} = 4, your solution should output n2c+1n - 2c + 1 integers $\text{hash}\left(p^{(c)}\right), \text{hash}\left(p^{(c+1)}\right), \ldots, \text{hash}\left(p^{(n-c)}\right)$, where 0hash(p(i))<109+70 \leq \text{hash}\left(p^{(i)}\right) < 10^9 + 7. Note that this should not be done if task=3\text{task} = 3.

Further interaction occurs only if task=3\text{task} = 3 or task=4\text{task} = 4.

The next line contains a single integer qq (1q501 \leq q \leq 50) --- the number of queries.

Then qq times, in each line, a query kik_i (ckincc \leq k_i \leq n - c) appears. As a response, you should output a permutation on a separate line. The sharpness of this permutation should be exactly kik_i. If task=4\text{task} = 4, 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 22.

In the second sample the sharpness equals to 11, it is 2\leq 2.

In the third example the lines have sharpness 22, 33, 44.

In the forth example we build lines that have sharpness 22 and 33. 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 nn cc Additional constraints Required Groups Comment
0 - - - - Examples.
1 8 1 n20000n \leq 20000 xi<xi+1,yi<yi+1x_i < x_{i+1}, y_i < y_{i+1}
2 6 n10n \leq 10 random points
3 5 n1000n \leq 1000 2
4 n20000n \leq 20000 2 - 3
5 6 - 1 - 4
6 17 2 n=80000n = 80000 c=800c = 800 -
7 3 xi<xi+1,yi<yi+1x_i < x_{i+1}, y_i < y_{i+1}
8 4 n=50n = 50 c=25c = 25 random points
9 n=200n = 200 c=80c = 80
10 n=1000n = 1000 c=300c = 300
11 3 n=5000n = 5000 c=600c = 600
12 n=80000n = 80000 c=35000c = 35000
13 c=5000c = 5000 12
14 c=2000c = 2000 - 12 - 13
15 2 c=800c = 800 7, 12 - 14
16 6 4 xi<xi+1,yi<yi+1x_i < x_{i+1}, y_i < y_{i+1} -
17 3 n=5000n = 5000 c=600c = 600 random points
18 n=80000n = 80000 c=35000c = 35000
19 c=5000c = 5000 18
20 c=2000c = 2000 - 18 - 19
21 2 c=800c = 800 16, 18 - 20

In the groups where it is indicated that the points are random, all coordinates of all points xix_i, yiy_i are randomly generated with equal probability in the interval [109,109][-10^9, 10^9].