Accurate XOR
Chef has a tree consisting of $N$ nodes, rooted at node $1$. The parent of the $i^{th}\;(2\le i \le N)$ node in the tree is the node $P_i$. Chef wants to assign a binary value (`0` or `1`) to every node of the tree. The **Xor-value** of a node is defined as the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of all the binary values present in the [subtree](https://xlinux.nist.
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.
Sign in to chat with the tutor and save your progress.
Sign in to start