#P1637. 陈千语不是啥龙 [EGOI 2025 Dark Ride]
陈千语不是啥龙 [EGOI 2025 Dark Ride]
Background
Yvonne and Chen Qianyu are playing a game.
Problem
Chen Qianyu has depot loaders in front of her, numbered to from left to right. Each depot loader can be set to output one of two minerals: Originium Ore or Ferrium Ore. The depot loaders are connected to a tansport belt system that shuffles the outputs from the depot loaders in a fixed order and delivers them to output ports, but Chen Qianyu does not know this order. The output ports are numbered to from left to right. In front of each output port stands a "Flashfreezer".
Yvonne will have the Flashfreezers report numbers from left to right, following these rules:
- The leftmost Flashfreezer reports .
- For each subsequent Flashfreezer, if the mineral in front of him is different from the mineral in front of the Flashfreezer immediately to his left, he reports the number reported by the left neighbor plus ; otherwise, he reports the same number as the left neighbor.
Then, Yvonne tells Chen Qianyu the number reported by the last Flashfreezer.
Chen Qianyu can conduct multiple experiments: each time, she can freely set the mineral types for all input ports, and then she receives the last Flashfreezer's reported number. Her goal is to determine which two depot loaders correspond to the two endpoint output ports (output port and output port ).
Since Chen Qianyu is exceptionally intelligent, she has called upon you, the Endministrator, to help her win the game.
Interaction
- Your program should first read a line containing an integer : the number of depot loaders.
- Then, your program should interact with the interactor. To start an experiment, you should output a line starting with a question mark
?, followed by a string of length consisting of (for Originium Ore) and (for Ferrium Ore), indicating how you set the outputs of the depot loaders. After that, your program should read an integer , which is the number reported by the last Flashfreezer. - When you are ready to answer, output a line starting with an exclamation mark
!, followed by two integers and . For your answer to be accepted, these must be the depot loader numbers corresponding to output port and output port , in any order. After this, your program should exit.
The interactor is non-adaptive, meaning the mapping between depot loaders and output ports is fixed before the interaction starts.
Make sure to flush the standard output after each experiment; otherwise, your program might be judged as Time Limit Exceeded. In Python, using input() to read lines automatically flushes output. In C++, cout << endl; flushes the output in addition to printing a newline; if you use printf, use fflush(stdout).
Example 1
Hidden mapping:
| depot loader | Output Port |
|---|---|
| 2 | |
| 1 | |
| 0 | |
| 3 | |
| 4 |
| Interactor Output | Your Output |
|---|---|
5 |
|
? 10001 |
|
3 |
|
? 10110 |
|
3 |
|
! 2 4 |
In Example 1, there are depot loaders.
In the first experiment, the minerals in front of the Flashfreezers (from left to right) are Originium Ore, Originium Ore, Ferrium Ore, Originium Ore, Ferrium Ore, and their reported numbers are , so the interactor outputs .
In the second experiment, the minerals are Ferrium Ore, Originium Ore, Ferrium Ore, Ferrium Ore, Originium Ore, and their reported numbers are , so the interactor outputs .
Finally, Chen Qianyu concludes that the depot loaders corresponding to output port and output port are the nd and th depot loaders (order irrelevant). Both ! 2 4 and ! 4 2 are acceptable answers.
Example 2
Hidden mapping:
| depot loader | Output Port |
|---|---|
| 2 | |
| 0 | |
| 1 |
| Interactor Output | Your Output |
|---|---|
3 |
|
? 111 |
|
0 |
|
? 110 |
|
2 |
|
? 000 |
|
0 |
|
! 1 0 |
In Example 2, there are depot loaders.
In the first experiment, the minerals are Ferrium Ore, Ferrium Ore, Ferrium Ore, and the reported numbers are , so the interactor outputs .
In the second experiment, the minerals are Ferrium Ore, Originium Ore, Ferrium Ore, and the reported numbers are , so the interactor outputs .
In the third experiment, the minerals are Originium Ore, Originium Ore, Originium Ore, and the reported numbers are , so the interactor outputs .
Finally, Chen Qianyu concludes that the depot loaders corresponding to output port and output port are the th and st depot loaders (order irrelevant). Both ! 0 1 and ! 1 0 are acceptable answers.
Example 3
Hidden mapping:
| depot loader | Output Port |
|---|---|
| 0 | |
| 1 | |
| 2 | |
| 3 |
| Interactor Output | Your Output |
|---|---|
4 |
|
? 1010 |
|
3 |
|
! 0 3 |
In Example 3, there are depot loaders.
In the first experiment, the minerals are Ferrium Ore, Originium Ore, Ferrium Ore, Originium Ore, and their reported numbers are , so the interactor outputs .
Finally, Chen Qianyu concludes that the depot loaders corresponding to output port and output port are the th and rd depot loaders (order irrelevant). Both ! 0 3 and ! 3 0 are acceptable answers.
Constraints and Notes
For all input data, it holds that:
- You can initiate at most experiments (outputting the final answer does not count towards this limit). If you exceed this limit, your submission will be judged as "Wrong Answer".
Detailed subtask constraints and scores are shown in the table below.
| Subtask | Score | Additional Constraints |
|---|---|---|
| depot loader corresponds to output port | ||
| is even. One of the endpoint output ports corresponds to a depot loader in the first half , and the other endpoint output port corresponds to a depot loader in the second half | ||
| No additional constraints |
Related
In following contests: