← All problemsSign in

Good Paths On Tree

You are given a weighted tree. A simple path on the tree between vertices $u$ and $v$ is defined as good if the xor sum of all the edge weights in path is 0. See example for further details. You have to perform two types of queries on it : a) $1$ $x$ : You will be given a node $x$. and you have to find the number of good paths starting at node $x$, and ending at any of the node in the tree. b

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