← All problemsSign in

Node XOR

You are given Tree with $n$ vertices. weight of $i$th vertice is $a[i]$. You will be asked $Q$ query. In each query you will be given two vertices `$l$` and `$r$` you have to tell xor of weight assign to vertices in path from $l$ to $r$ including $l$ and $r$. if $l,w_1,w_2,\dots,w_k,r$ are verice in path $l$ to $r$ than you have to calculate $a_l \oplus a_{w_1}\oplus a_{w_2}\oplus \dots\oplus a

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