#abc313d. D - Odd or Even
D - Odd or Even
Score : points
问题描述
这是一个 交互式任务(在此任务中,您的程序与裁判通过标准输入和输出进行交互)。
您已知一个整数 和一个 奇数 。
裁判手中有一个隐藏的长度为 的序列 ,其中包含 和 。
虽然您不能直接访问序列 的元素,但您最多可以向裁判提出 次以下查询:
- 选择 到 之间互不相同的整数 , 和 ,询问 的奇偶性。
通过最多 次查询确定 并打印答案。
这里需要注意的是,裁判是自适应的。换句话说,只要修改后的序列与过去查询的回答保持一致,裁判可以随时修改 序列的内容。
因此,只有当满足以下条件时,您的程序才被视为正确,否则视为错误:
- 您的程序打印出与当前为止所有查询回答一致的序列,并且这是唯一符合这一条件的序列。
以上为通义千问 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 and an odd number .
The judge has a hidden length- sequence consisting of and .
While you cannot directly access the elements of sequence , you are allowed to ask the judge the following query at most times.
- Choose distinct integers , and between and , inclusive, to ask the parity of .
Determine by at most queries, and print the answer.
Here, the judge is adaptive. In other words, the judge may modify the contents of 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
- is odd.
- is or .
Input and Output
This is an interactive task (where your program and the judge interact via Standard Input and Output).
First of all, receive and from Standard Input.
Then, repeat asking queries until you can uniquely determine .
Each query should be printed to Standard Output in the following format, where , and are distinct integers between and , inclusive.
The response to the query is given from Standard Input in the following format.
Here, denotes the response to the query.
-
is
0
when is even, and -
is
1
when is odd.
However, if and do not satisfy the constraints, or the number of queries exceeds , then 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 , print those elements in the following format, and terminate the program immediately.
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 as long as it is consistent with the responses to the past queries.
Sample Interaction
In the following interaction, and . Note that the following output itself will result in WA.
Here, is indeed consistent with the responses, but so is , so sequence is not uniquely determined. Thus, this program is considered incorrect.
Input | Output | Description |
---|---|---|
5 3 | First, you are given integers $N$ and $K$. | |
? 2 4 1 | You ask a query with $(x_1, x_2, x_3) = (2, 4, 1)$. | |
0 | The response to the query is $0$, so the judge returns that value. | |
? 5 3 2 | You ask a query with $(x_1, x_2, x_3) = (5, 3, 2)$. | |
1 | The response to the query is $1$, so the judge returns that value. | |
! 1 0 1 1 0 | You 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