F - XOR Matching Editorial by inszva


If \(k \geq 2^M\), there’s obviously no answer.
If \(k = 0\), we can put elements from \(0\) to \(2^M-1\) one by one, and then put elements from \(2^M-1\) to \(0\) one by one.
If \( k \not=0\), we can construct a sequence using the following method. First, we put one \(k\) in the center of this sequence. Then we symmetrically put all \(0 \leq x \lt 2^M, x \not= k\) on both side of k. Finally we put the other \(k\) to the end. This sequence will look like this: \(x, y, z ... k, ... z, y, x, k \). We can easily find for every \(0 \leq x \lt 2^M, x \not= k\), it satisfy the condition. For k, \( \sum_{0 \leq x \lt 2^M, x \not= k}^{\oplus} = k \oplus \sum_{0 \leq x \lt 2^M}^{\oplus}\). When \(M \geq 2\), \(\sum_{0 \leq x \lt 2^M}^{\oplus} = 0\), our construction will satisfy all condition. But when \(M=1\), we can find no answer (sample 2).

posted:
last update: