Adjacent Replace

AtCoder
IDarc199_b
Time2000ms
Memory256MB
Difficulty
You are given a sequence of non-negative integers of length $N$: $A=(A_1,A_2,\ldots,A_N)$ and a non-negative integer $K$. Determine whether it is possible to make $A_1=K$ by performing the following operation at most $10^4$ times: * Choose an integer $i\ (1\leq i\leq N-1)$. Let $x=A_i\oplus A_{i+1}$, then replace both $A_i,A_{i+1}$ with $x$. Here, $\oplus$ denotes the bitwise XOR operation. If possible, output one such sequence of operations. You are given $T$ test cases, so solve each of them. What is bitwise XOR operation?The bitwise XOR of non-negative integers $A, B$, denoted $A \oplus B$, is defined as follows: * When $A \oplus B$ is written in binary, the digit in the $2^k$ ($k \geq 0$) place is $1$ if exactly one of $A, B$ has $1$ in the $2^k$ place when written in binary, and $0$ otherwise. For example, $3 \oplus 5 = 6$ (in binary: $011 \oplus 101 = 110$). ## Constraints * $1\leq T\leq 50$ * $3\leq N\leq 60$ * $0\leq A_i,K\lt 2^{60}$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $T$ $\mathrm{case}_1$ $\mathrm{case}_2$ $\vdots$ $\mathrm{case}_T$ Each test case is given in the following format: $N$ $K$ $A_1$ $A_2$ $\ldots$ $A_N$ [samples]
Samples
Input #1
5
3 5
2 3 4
3 0
2 3 4
3 8
2 3 4
3 2
2 3 4
4 10
2 3 4 8
Output #1
Yes
2
2 1
Yes
3
1 1 1
No
Yes
0

Yes
4
2 3 2 1

For the first test case, you can make $A_1=5$ by performing the operations as follows:

1.  Choose $i=2$. $A$ becomes $(2,7,7)$.
2.  Choose $i=1$. $A$ becomes $(5,5,7)$.

For the second test case, you can make $A_1=0$ by performing the operations as follows:

1.  Choose $i=1$. $A$ becomes $(1,1,4)$.
2.  Choose $i=1$. $A$ becomes $(0,0,4)$.
3.  Choose $i=1$. $A$ becomes $(0,0,4)$.

For the third test case, it is impossible to make $A_1=8$ with at most $10^4$ operations.
API Response (JSON)
{
  "problem": {
    "name": "Adjacent Replace",
    "description": {
      "content": "You are given a sequence of non-negative integers of length $N$: $A=(A_1,A_2,\\ldots,A_N)$ and a non-negative integer $K$. Determine whether it is possible to make $A_1=K$ by performing the following o",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc199_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a sequence of non-negative integers of length $N$: $A=(A_1,A_2,\\ldots,A_N)$ and a non-negative integer $K$.\nDetermine whether it is possible to make $A_1=K$ by performing the following o...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments