#P16914. [JLCPC 2026] 隐藏的 k 元组

    ID: 19232 远端评测题 2000ms 1024MiB 尝试: 0 已通过: 0 显示难度提高 上传者: 标签>二分吉林交互题Special JudgeO2优化2026省赛/邀请赛

[JLCPC 2026] 隐藏的 k 元组

Problem Description

This is an interactive problem.

There is a hidden partition that divides the integers 1,2,…,n1, 2, \ldots, n into nk\dfrac{n}{k} pairwise disjoint kk-tuples. It is guaranteed that nn is a multiple of kk. You need to find all hidden kk-tuples by making queries.

In one query, you may choose a set S⊆{1,2,…,n}S \subseteq \{1, 2, \ldots, n\}. The interactor will return an integer indicating how many hidden kk-tuples are fully contained in SS.

The number of queries you make must not exceed n×⌈log⁡2n⌉n \times \lceil \log_2 n \rceil.

⌈⋅⌉\lceil \cdot \rceil is the ceiling function. ⌈x⌉\lceil x \rceil is the smallest integer not less than xx. For example, ⌈7⌉=7\lceil 7 \rceil = 7, and ⌈3.14⌉=4\lceil 3.14 \rceil = 4.

Input Format

At the start, the interactor outputs one line with two integers nn and kk (2≤n≤3002 \le n \le 300, 2≤k≤n2 \le k \le n, and nn is a multiple of kk).

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 rr, which is the number of hidden kk-tuples fully contained in your queried set.

Output Format

You can make queries in the following form:

? c x1 x2 … xc\texttt{? c $x_1$ $x_2$ $\ldots$ $x_c$}

Here, 0≤c≤n0 \le c \le n, and x1,x2,…,xcx_1, x_2, \ldots, x_c must be pairwise distinct integers satisfying 1≤xi≤n1 \le x_i \le n.

This query means you choose the set S={x1,x2,…,xc}S=\{x_1,x_2,\ldots,x_c\}. The interactor will return an integer rr, which is the number of hidden kk-tuples fully contained in SS.

When you are sure about the answer, you need to output:

! a1 a2 … an\texttt{! $a_1$ $a_2$ $\ldots$ $a_n$}

Here, aia_i denotes the tuple index of the tuple that contains element ii. The indices must satisfy 1≤ai≤nk1 \le a_i \le \dfrac{n}{k}. 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 n×⌈log⁡2n⌉n \times \lceil \log_2 n \rceil. 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 kk-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, n=6n = 6, k=2k = 2, and the hidden tuples are {1,3}\{1, 3\}, {2,6}\{2, 6\}, and {4,5}\{4, 5\}.

$$\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 {1,3,5}\{1, 3, 5\}: the tuple {1,3}⊆S\{1, 3\} \subseteq S, so the answer is 11.
  • Query {2,3,4,5}\{2, 3, 4, 5\}: the tuple {4,5}⊆S\{4, 5\} \subseteq S, so the answer is 11.
  • Query {1,2,3,4,5,6}\{1, 2, 3, 4, 5, 6\}: all three tuples are contained, so the answer is 33.
  • Output [1,2,1,3,3,2][1, 2, 1, 3, 3, 2] means: elements 1,31, 3 form group 11; elements 2,62, 6 form group 22; elements 4,54, 5 form group 33.

Translated by ChatGPT 5