#P7321. 「PMOI-4」猜排列

    ID: 6630 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>交互题Special JudgeO2优化洛谷月赛

「PMOI-4」猜排列

Description

Xiao A has a permutation aa of length nn, 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 axmodaya_x \bmod a_y, where your query must satisfy ax>aya_x\gt a_y and xyx\ne y; otherwise, he will get unhappy and directly judge the query as invalid, which will lead to WA.
  • ? l S p: You need to give Xiao A a set SS of size ll and an integer pp, where S={x1,x2,x3,,xl}S=\{x_1,x_2,x_3,\ldots,x_l\}. For any 1il1\le i\le l, 1xin1\le x_i\le n, and all xix_i are pairwise distinct. Also, it must satisfy 1pn1\le p\le n and 1ln1\le l\le n. Xiao A will tell you all xkx_k in this set such that axkpa_{x_k} \ge p, returning in the following form: first an integer LL, then LL integers, indicating that there are LL such kk (note that what is returned are the elements of the set SS, not the indices within SS).

You can ask at most m1m_1 queries of type 11 and m2m_2 queries of type 22. In addition, for type 22 queries, the sum of the sizes of the queried sets must not exceed m3m_3, in order to guess the sequence.

Input Format

Input the permutation length nn and m1,m2,m3m_1,m_2,m_3 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) or cout.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 n=n= m1=m_1= m2=m_2= m3=m_3= Special Constraints
11 1010 44 11 44 None
22 5×1025 \times 10^2 2.5×1052.5\times 10^5
33 2×1042 \times 10^4 3×1053 \times 10^5 A
44 2020 10410^4 3030 None
55 5×1045 \times 10^4 3434 4×1054 \times 10^5
66 2525 1717 1.5×1051.5\times 10^5
77 55 1515

A: The permutation aa is guaranteed to be constructed randomly.

【Notes】

  1. Making an invalid query, or continuing to query after the interactive library has output more than mm numbers, will directly lead to WA.

  2. The top row in the Constraints table uses ==, not \le.

Translated by ChatGPT 5