#P10887. 【MX-S3-T3】「FeOI Round 1」再演
【MX-S3-T3】「FeOI Round 1」再演
Background
Original problem link: https://oier.team/problems/S3C。
Problem Description
This is an interactive problem.
jt has a set of size . Each element in the set is an unordered integer pair . It is guaranteed that among the integers from to , each appears exactly once in the set.
For example, when , a valid set could be .
At the beginning, you only know , but you do not know what is.
Now one kind of operation is supported: you can give (), then jt will swap the positions of and in (if are in the same pair, or , then nothing happens).
For example, when , after performing , we have $S = \{(1, 5), (6, 3), (4, 2)\} = \{(1, 5), (2, 4), (3, 6)\}$.
At the very beginning and after each operation, for the current set , jt will tell you
For example, when , we have $res = \min(\max(1, 5), \max(2, 3), \max(4, 6)) = \min(5, 3, 6) = 3$.
Note that after jt tells you each time, jt will not undo the operations you made, i.e. your operations remain effective.
You need to guess the initial set within operations, i.e. the version before any swap operations.
It is guaranteed that the initial is fixed in advance, i.e. the interactor is not adaptive.
Interaction
This problem contains multiple test cases in a single test file.
First read the number of test cases .
Then there are test cases. For each test case, do the following process:
Input the size of and to start the interaction.
For each operation, first read , then output one line ^ i j to indicate that you want to perform the operation on .
After you have determined the answer, first output one line containing a single !, then output lines, each with two integers x y representing one pair in , and then get ready to read the next test case. You may output these pairs in any order, and the order inside each pair can also be arbitrary.
After each line you output, please flush the buffer:
- In C++, use
fflush(stdout)orcout.flush(). - In Pascal, use
flush(output). - In Python, use
stdout.flush(). - For other languages, please check the documentation yourself.
When the total number of operations over all testdata in a single test point does not exceed , it is guaranteed that the interactor runs within time and memory. That is, you can use at least of time and of memory.
Input Format
See "Interaction".
Output Format
See "Interaction".
2
3 100
3
3
4
2
1 0
2
^ 1 2
^ 3 6
^ 6 2
!
5 1
6 4
2 3
!
1 2
Hint
Sample Explanation
Note that the sample only describes one possible interaction process, and it may not be logically consistent (that is, the answer might be a random guess that happens to be correct).
For the first test case, initially , and jt tells you .
Then you swap , becomes , and jt tells you .
Then you swap , becomes , and jt tells you .
Then you swap , becomes , and jt tells you .
You output . You used operations, which does not exceed , so the answer is correct.
For the second test case, initially . You directly output . You used operations, which does not exceed , so the answer is correct.
Constraints
This problem uses bundled tests.
Let be the sum of all within a single test point.
For of the data, , , .
| Subtask ID | Score | |||
|---|---|---|---|---|
| () | ||||
means double factorial。
Translated by ChatGPT 5