Chef and XOR Queries
CodeChefOpen on judge ↗
Mr. X has given the Chef an undirected tree \( T \) with \( n \) nodes numbered from 1 to \( n \). Each edge \( e_i \) of the tree has a non-negative integer \( w_i \) written on it. But the edge weights are hidden from you. You have access only to the structure of the tree, i.e., you know all the edges \( e_i \). Mr. X has taught Chef how to compute the function \( f(u, v) = \) Bitwise \( XOR \)
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