← All problemsSign in

Xorred

CodeChefRating 2830Open on judge ↗

An array $B$ of length $M$ is called *magical* if its bitwise AND equals its bitwise XOR. That is, $(B_1 \ \&\ B_2\ \&\ \ldots\ \&\ B_M) = (B_1\oplus B_2\oplus\ldots\oplus B_M)$ should hold, where $\&$ denotes [bitwise AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND), and $\oplus$ denotes [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). For example, $[1, 1, 1]$ is *

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start