#P7321. 「PMOI-4」猜排列
「PMOI-4」猜排列
Description
Xiao A has a permutation of length , and he wants you to guess this permutation. You can only make the following two types of queries:
! x y: He will tell you the value of , where your query must satisfy and ; otherwise, he will get unhappy and directly judge the query as invalid, which will lead toWA.? l S p: You need to give Xiao A a set of size and an integer , where . For any , , and all are pairwise distinct. Also, it must satisfy and . Xiao A will tell you all in this set such that , returning in the following form: first an integer , then integers, indicating that there are such (note that what is returned are the elements of the set , not the indices within ).
You can ask at most queries of type and queries of type . In addition, for type queries, the sum of the sizes of the queried sets must not exceed , in order to guess the sequence.
Input Format
Input the permutation length and to start the interaction.
During the interaction, you may make the two types of queries described above. Whether it is the first type of query or the second type of query, the interactive library will return an integer.
After you are sure of the answer, output one line in the form A a[1] a[2] ... a[n-1] a[n] to stop the interaction.
After you output a line, 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.
Output Format
See "Interaction Method".
3 100 100 100
1 3
1 2
? 3 1 2 3 3
? 2 1 2 2
A 1 2 3
Hint
【Constraints】
This problem uses bundled testdata.
| Subtask ID | Score | Special Constraints | ||||
|---|---|---|---|---|---|---|
| None | ||||||
| A | ||||||
| None | ||||||
A: The permutation is guaranteed to be constructed randomly.
【Notes】
-
Making an invalid query, or continuing to query after the interactive library has output more than numbers, will directly lead to WA.
-
The top row in the Constraints table uses , not .
Translated by ChatGPT 5
京公网安备 11011102002149号