No.2819 Binary Binary-Operator
タグ : / 解いたユーザー数 89
作問者 :
みどりむし🦠
/ テスター :
FplusFplusF
This is an interactive problem.
Problem Statement
A binary operation $\otimes \colon \mathbb{B} \times \mathbb{B} \to \mathbb{B}$ on $\mathbb{B} \coloneqq \{\, 0, 1 \,\}$ satisfies all of the following:
- $0 \otimes 0 = P_{0, 0}$
- $0 \otimes 1 = P_{0, 1}$
- $1 \otimes 0 = P_{1, 0}$
- $1 \otimes 1 = P_{1, 1}$
You may ask the judge program the following question exactly $\bold 1$ time:
- First, freely choose a sequence $v = (v_1, v_2, \dots, v_n)$ of length $n$ satisfying all of the following:
- $\bold{3} \leq n < 256$
- $\{\, v_1, v_2, \dots, v_n \,\} \subset \mathbb{B}$
- Then, ask for the value of $( \cdots ((v_1 \otimes v_2) \otimes v_3) \otimes \cdots) \otimes v_n$.
For $X, Y$ with $\{\, X ,Y \,\} \subset \mathbb{B}$ given in the input, find the value of $X \otimes Y$.
Input and Output
This is an interactive problem (a problem in which your program and the judge program interact through input and output).
First, the judge program gives $X, Y$ through standard input in the following format:
$X \enspace Y$
Next, output the sequence $v$ and its length $n$ to standard output in the following format:
$n$ $v_1 \enspace v_2 \enspace \dots \enspace v_n$
In response to the question, the judge program gives the answer through standard input in the following format:
$t$Here, $t$ is the value of $( \cdots ((v_1 \otimes v_2) \otimes v_3) \otimes \cdots) \otimes v_n$.
Finally, output the value of $X \otimes Y$ you found to standard output on one line, and terminate the program.
Notes
- Each time you output, add a newline at the end and flush standard output.
- If your output does not meet the requirements, the judge result is undefined. This includes printing extra spaces or newlines.
- Terminate the program immediately after the interaction ends.
Constraints
- $\{\, P_{0, 0}, P_{0, 1}, P_{1, 0}, P_{1, 1} \,\} \subset \mathbb{B}$
- $\{\, X, Y \,\} \subset \mathbb{B}$
- The values of $P_{0, 0}, P_{0, 1}, P_{1, 0}, P_{1, 1}$ are fixed for each test case
Sample
The following is an example of the interaction when $(P_{0, 0}, P_{0, 1}, P_{1, 0}, P_{1, 1}) = (1, 0, 1, 0)$:
| Input | Output | Meaning | Remarks |
|---|---|---|---|
0 0 |
$(X, Y) = (0, 0)$ | ||
30 0 0 |
$v = (v_1, v_2, v_3) = (0, 0, 0)$ | ||
1 |
$(v_1 \otimes v_2) \otimes v_3 = (0 \otimes 0) \otimes 0 = 1 \>\>\>\text{---}\> (\star)$ | We have $(0 \otimes 0) \otimes 0 = P_{0, 0} \otimes 0 = 1 \otimes 0 = P_{1, 0} = 1$. | |
1 |
$X \otimes Y = 0 \otimes 0 = 1$ | If we assume $0 \otimes 0 = 0$, then $(0 \otimes 0) \otimes 0 = 0 \otimes 0 = 0$, which contradicts $(\star)$. Therefore, we see that $0 \otimes 0 = 1$. |
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。