#P10645. [NordicOI 2022] 夸克显微镜 Quark Microscopy
[NordicOI 2022] 夸克显微镜 Quark Microscopy
Background
Translated from Nordic Olympiad in Informatics 2022 Quark Microscopy。If you find that the interaction library is broken, please contact the problem porter qvq。
。
Problem Description
This is terrible! Niels’s beloved atom was hit by cosmic rays and split into many quarks. Niels urgently wants to find these quarks and then put them back together, so he asked you to help.
These quarks are located on a line segment of length meter ( ångström). Luckily, you have a very accurate but somewhat strange quark microscope that can detect and measure nearby quarks. However, due to quantum effects, it cannot directly tell you the position of the quark closest to the measurement point. Instead, it tells you the position of the second-closest quark to the measurement point, as well as how many quarks are tied for being the second-closest.
More precisely, you may perform a measurement at position on the line segment. For each measurement, the distances from each quark to are computed and sorted in nondecreasing order as . You are given , and the number of indices such that (which will only be or ). After making enough measurements, you need to output the position of every quark.
Each quark’s position is a positive integer in (unit: ångström), measured from the start of the segment. Due to the Pauli exclusion principle, no two quarks share the same position。
Input Format
Your program interacts with the interaction library through standard input and output.
The first line contains two positive integers , representing the number of quarks and the subtask number.
Then, your program starts interacting with the library:
-
? x: Query the second-farthest quark from . The library returns two integers , where is the distance to the second-farthest quark, and is the number of quarks whose distance to equals (only or ). You must ensure . -
!: Output the quark positions. You may output these positions in any order. After answering, there should be no extra queries. You must ensure .
Note: During interaction, you must flush the output buffer after each output.
Below are some common ways to flush the buffer in popular languages:
- C++:
fflush(stdout)orcout.flush()。In particular, printing a newline usingstd::endlalso flushes the buffer. - C:
fflush(stdout)。
Output Format
See [Input Format].
3 3
6 1
4 1
1 2
? 5
? 15
? 11
! 11 10 12
3 1
2 1
1 2
2 1
45 1
? 1
? 2
? 3
? 47
! 1 3 92
Hint
Constraints
- ;
- 。
Scoring
| Subtask ID | Score | Restriction |
|---|---|---|
| There is a quark at position | ||
| All quark positions are even | ||
| No additional restrictions |
Here is a constant. Let be the maximum number of queries you make in a subtask. The value of is given in the table below:
| Limit on | |
|---|---|
To make local testing easier, we provide testing_tools.py, which can be downloaded from the attachments. For usage instructions, see the header of the file.
Translated by ChatGPT 5