問題一覧 > 通常問題

No.2819 Binary Binary-Operator

レベル : / AI推定難易度 : 1400 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 89
作問者 : みどりむし🦠 / テスター : FplusFplusF viral8 achapi 👑 AngrySadEight
お気に入りにしたユーザー ProblemId : 10948 / 自分の提出
問題文最終更新日: 2024-07-27 10:25:25
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 438 (順位表) の他の問題:

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}$
Here, the $4$ numbers $P_{0, 0}, P_{0, 1}, P_{1, 0}, P_{1, 1} \scriptsize \; (\in \mathbb{B})$ are all hidden and are not given to you.

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)$
3
0 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$.
Note that for all test cases, the values of $P_{0, 0}, P_{0, 1}, P_{1, 0}, P_{1, 1}, X, Y$ are each $0$ or $1$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。