Tree Xor
You are given a **weighted** tree. The distance from node $x$ to node $y$ is calculated as follows: - Let there be $k$ edges in the shortest path from node $x$ to $y$. - Let the weight of these edges, in the same **order** (from $x$ to $y$), be denoted as $e_1, e_2, \ldots, e_k$. - Then, the distance from $x$ to $y$ is denoted as: $d(x, y) = f(e_1, 0) \oplus f(e_2, 1) \oplus f(e_3, 2) \op
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