#P16914. [JLCPC 2026] 隐藏的 k 元组
[JLCPC 2026] 隐藏的 k 元组
Problem Description
This is an interactive problem.
There is a hidden partition that divides the integers into pairwise disjoint -tuples. It is guaranteed that is a multiple of . You need to find all hidden -tuples by making queries.
In one query, you may choose a set . The interactor will return an integer indicating how many hidden -tuples are fully contained in .
The number of queries you make must not exceed .
is the ceiling function. is the smallest integer not less than . For example, , and .
Input Format
At the start, the interactor outputs one line with two integers and (, , and is a multiple of ).
The hidden partition is kept by the interactor and will not be given directly.
After each time you output a valid query, the interactor returns one line with an integer , which is the number of hidden -tuples fully contained in your queried set.
Output Format
You can make queries in the following form:
Here, , and must be pairwise distinct integers satisfying .
This query means you choose the set . The interactor will return an integer , which is the number of hidden -tuples fully contained in .
When you are sure about the answer, you need to output:
Here, denotes the tuple index of the tuple that contains element . The indices must satisfy . If two elements belong to the same hidden tuple, their indices must be the same; if two elements belong to different hidden tuples, their indices must be different. The order of the tuple indices can be arbitrary.
The number of queries you make must not exceed . After outputting the final answer, your program should terminate immediately.
Note that after each query or final answer, you must flush the output buffer. For example, in C++ you can use fflush(stdout) or cout << flush.
If your output format is invalid, the query limit is exceeded, or the final answer is wrong, you will get Wrong Answer or Presentation Error.
The interactor is non-adaptive, meaning all -tuples are fixed before the interaction starts and will not change as queries are made.
6 2
1
1
3
? 3 1 3 5
? 4 2 3 4 5
? 6 1 2 3 4 5 6
! 1 2 1 3 3 2
Hint
In the example below, , , and the hidden tuples are , , and .
$$\def\arraystretch{1.5} \begin{array}{|l|c|} \hline \textbf{Program} & \textbf{Interactor} \\ \hline & \verb!6 2! \\ \hline \verb!? 3 1 3 5! & \verb!1! \\ \hline \verb!? 4 2 3 4 5! & \verb!1! \\ \hline \verb!? 6 1 2 3 4 5 6! & \verb!3! \\ \hline \verb|! 1 2 1 3 3 2| & \\ \hline \end{array}$$- Query : the tuple , so the answer is .
- Query : the tuple , so the answer is .
- Query : all three tuples are contained, so the answer is .
- Output means: elements form group ; elements form group ; elements form group .
Translated by ChatGPT 5