#abc313d. D - Odd or Even

D - Odd or Even

Score : 550550 points

问题描述

这是一个 交互式任务(在此任务中,您的程序与裁判通过标准输入和输出进行交互)。

您已知一个整数 NN 和一个 奇数 KK
裁判手中有一个隐藏的长度为 NN 的序列 A=(A1,A2,,AN)A = (A_1, A_2, \dots, A_N),其中包含 0011

虽然您不能直接访问序列 AA 的元素,但您最多可以向裁判提出 NN 次以下查询:

  • 选择 11NN 之间互不相同的整数 x1,x2,x_1, x_2, \dots, 和 xKx_K,询问 Ax1+Ax2++AxKA_{x_1} + A_{x_2} + \dots + A_{x_K} 的奇偶性。

通过最多 NN 次查询确定 (A1,A2,,AN)(A_1, A_2, \dots, A_N) 并打印答案。
这里需要注意的是,裁判是自适应的。换句话说,只要修改后的序列与过去查询的回答保持一致,裁判可以随时修改 AA 序列的内容。
因此,只有当满足以下条件时,您的程序才被视为正确,否则视为错误:

  • 您的程序打印出与当前为止所有查询回答一致的序列,并且这是唯一符合这一条件的序列。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

This is an interactive task (where your program and the judge interact via Standard Input and Output).

You are given an integer NN and an odd number KK.
The judge has a hidden length-NN sequence A=(A1,A2,,AN)A = (A_1, A_2, \dots, A_N) consisting of 00 and 11.

While you cannot directly access the elements of sequence AA, you are allowed to ask the judge the following query at most NN times.

  • Choose distinct integers x1,x2,x_1, x_2, \dots, and xKx_K between 11 and NN, inclusive, to ask the parity of Ax1+Ax2++AxKA_{x_1} + A_{x_2} + \dots + A_{x_K}.

Determine (A1,A2,,AN)(A_1, A_2, \dots, A_N) by at most NN queries, and print the answer.
Here, the judge is adaptive. In other words, the judge may modify the contents of AA as long as it is consistent with the responses to the past queries.
Therefore, your program is considered correct if the output satisfies the following condition, and incorrect otherwise:

  • your program prints a sequence consistent with the responses to the queries so far, and that is the only such sequence.

Constraints

  • 1K<N10001 \leq K \lt N \leq 1000
  • KK is odd.
  • AiA_i is 00 or 11.

Input and Output

This is an interactive task (where your program and the judge interact via Standard Input and Output).

First of all, receive NN and KK from Standard Input.

NN KK

Then, repeat asking queries until you can uniquely determine (A1,A2,,AN)(A_1, A_2, \dots, A_N).

Each query should be printed to Standard Output in the following format, where x1,x2,x_1, x_2, \dots, and xKx_K are KK distinct integers between 11 and NN, inclusive.

?? x1x_1 x2x_2 \dots xKx_K

The response to the query is given from Standard Input in the following format.

TT

Here, TT denotes the response to the query.

  • TT is 0 when Ax1+Ax2++AxKA_{x_1} + A_{x_2} + \dots + A_{x_K} is even, and

  • TT is 1 when Ax1+Ax2++AxKA_{x_1} + A_{x_2} + \dots + A_{x_K} is odd.

However, if x1,x2,x_1, x_2, \dots and xKx_K do not satisfy the constraints, or the number of queries exceeds NN, then TT is -1.

If the judge returns -1, your program is already considered incorrect, so terminate the program immediately.

When you can determine all the elements of AA, print those elements in the following format, and terminate the program immediately.

!! A1A_1 A2A_2 \dots ANA_N

Notes

  • Print a newline and flush Standard Output at the end of each message. Otherwise, you may get a TLE verdict.
  • The verdict will be indeterminate if there is malformed output during the interaction or your program quits prematurely.
  • Terminate the program immediately after printing the answer, or the verdict will be indeterminate.
  • The judge for this problem is adaptive. This means that the judge may modify the contents of AA as long as it is consistent with the responses to the past queries.

Sample Interaction

In the following interaction, N=5N=5 and K=3K=3. Note that the following output itself will result in WA.
Here, A=(1,0,1,1,0)A = (1, 0, 1, 1, 0) is indeed consistent with the responses, but so is (0,0,1,0,0)(0, 0, 1, 0, 0), so sequence AA is not uniquely determined. Thus, this program is considered incorrect.

InputOutputDescription
5 3First, you are given integers $N$ and $K$.
? 2 4 1You ask a query with $(x_1, x_2, x_3) = (2, 4, 1)$.
0The response to the query is $0$, so the judge returns that value.
? 5 3 2You ask a query with $(x_1, x_2, x_3) = (5, 3, 2)$.
1The response to the query is $1$, so the judge returns that value.
! 1 0 1 1 0You print $(1, 0, 1, 1, 0)$ to guess $A$. Since sequence $A$ is not uniquely determined, the verdict will be WA.

update @ 2024/3/10 08:55:34