9948: ABC313 —— D - Odd or Even
[Creator : ]
Description
This is an interactive task (where your program and the judge interact via Standard Input and Output).
You are given an integer $N$ and an odd number $K$.
The judge has a hidden length-$N$ sequence $A = (A_1, A_2, \dots, A_N)$ consisting of $0$ and $1$.
While you cannot directly access the elements of sequence $A$, you are allowed to ask the judge the following query at most $N$ times.
- Choose distinct integers $x_1, x_2, \dots$, and $x_K$ between $1$ and $N$, inclusive, to ask the parity of $A_{x_1} + A_{x_2} + \dots + A_{x_K}$.
Determine $(A_1, A_2, \dots, A_N)$ by at most $N$ queries, and print the answer.
Here, the judge is adaptive. In other words, the judge may modify the contents of $A$ 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.
You are given an integer $N$ and an odd number $K$.
The judge has a hidden length-$N$ sequence $A = (A_1, A_2, \dots, A_N)$ consisting of $0$ and $1$.
While you cannot directly access the elements of sequence $A$, you are allowed to ask the judge the following query at most $N$ times.
- Choose distinct integers $x_1, x_2, \dots$, and $x_K$ between $1$ and $N$, inclusive, to ask the parity of $A_{x_1} + A_{x_2} + \dots + A_{x_K}$.
Determine $(A_1, A_2, \dots, A_N)$ by at most $N$ queries, and print the answer.
Here, the judge is adaptive. In other words, the judge may modify the contents of $A$ 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.
Input
First of all, receive $N$ and $K$ from Standard Input.
```
$N$ $K$
```
Then, repeat asking queries until you can uniquely determine $(A_1, A_2, \dots, A_N)$.
Each query should be printed to Standard Output in the following format, where $x_1, x_2, \dots$, and $x_K$ are $K$ distinct integers between $1$ and $N$, inclusive.
```
$?$ $x_1$ $x_2$ $\dots$ $x_K$
```
The response to the query is given from Standard Input in the following format.
```
$T$
```
Here, $T$ denotes the response to the query.
- $T$ is `0` when $A_{x_1} + A_{x_2} + \dots + A_{x_K}$ is even, and
- $T$ is `1` when $A_{x_1} + A_{x_2} + \dots + A_{x_K}$ is odd.
However, if $x_1, x_2, \dots$ and $x_K$ do not satisfy the constraints, or the number of queries exceeds $N$, then $T$ 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 $A$, print those elements in the following format, and terminate the program immediately.
```
$!$ $A_1$ $A_2$ $\dots$ $A_N$
```
```
$N$ $K$
```
Then, repeat asking queries until you can uniquely determine $(A_1, A_2, \dots, A_N)$.
Each query should be printed to Standard Output in the following format, where $x_1, x_2, \dots$, and $x_K$ are $K$ distinct integers between $1$ and $N$, inclusive.
```
$?$ $x_1$ $x_2$ $\dots$ $x_K$
```
The response to the query is given from Standard Input in the following format.
```
$T$
```
Here, $T$ denotes the response to the query.
- $T$ is `0` when $A_{x_1} + A_{x_2} + \dots + A_{x_K}$ is even, and
- $T$ is `1` when $A_{x_1} + A_{x_2} + \dots + A_{x_K}$ is odd.
However, if $x_1, x_2, \dots$ and $x_K$ do not satisfy the constraints, or the number of queries exceeds $N$, then $T$ 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 $A$, print those elements in the following format, and terminate the program immediately.
```
$!$ $A_1$ $A_2$ $\dots$ $A_N$
```
Output
Constraints
- $1 \leq K \lt N \leq 1000$
- $K$ is odd.
- $A_i$ is $0$ or $1$.
- $K$ is odd.
- $A_i$ is $0$ or $1$.