Problem B
Quark Microscopy
Disaster has struck! Niels’ precious pet atom has been hit by a cosmic ray, and split up into a mass of individual quarks. Niels is now desperate to find the quarks and piece them together again, and has turned to you for help.
The
To be more precise: you can make measurements at integer
positions
Each quark has an integer position between
Depending on the number of measurements performed, your program will receive different amounts of points.
Interaction
Your program will interact with the judge by reading from
standard in and writing to standard out. First, the judge will
output a line containing the number of quarks
Then, your program can make queries of the following forms:
-
? x (
): find the distance to the second closest quark to . The judge will respond with two space-separated numbers , , where is the distance to the second closest quark, and is the number of quarks at that distance (either or ). -
!
: guess the positions of the quarks ( ). may be given in any order. No additional queries should be made after this.
After each query, you should make sure to flush standard output before reading the judge’s response, or your solution may end up graded as Time Limit Exceeded. In Python this happens automatically, and in C++ it happens when using cout << endl; to print a newline. In C you can use fflush(stdout); after printf.
If you make an invalid query, your program may receive either Wrong Answer or Run Time Error.
To facilitate testing of your solution, we provide a simple tool that you can download from the sidebar of the Kattis page for this problem. See the comment at the top of the file for a description of how to use it.
Scoring
Your solution will be tested on a set of test groups, each worth up to a number of points. To get the points for a test group you need to solve all test cases in the test group.
Group |
Points |
Constraints |
|
|
One of the quarks is located at position |
|
|
All coordinates are even |
|
|
No additional constraints |
For each test group, let
Constraints |
|
|
|
|
|
|
|
|
|
|
|
Read | Sample Interaction 1 | Write |
---|
3 3
? 5
6 1
? 15
4 1
? 11
1 2
! 11 10 12
Read | Sample Interaction 2 | Write |
---|
3 1
? 1
2 1
? 2
1 2
? 3
2 1
? 47
45 1
! 1 3 92