← All problemsSign in

Black and White Tree

CodeChefRating 3008Open on judge ↗

You are given an undirected tree having $N$ nodes. The color of each node is either Black or White. In one step, you can choose a node $u$, toggle the color of the chosen node $u$, as well as toggle the colors of all the nodes $v$, such that $\{u, v\}$ is an edge in the tree. Can you find out the minimum number of steps required to make the color of all the nodes black? **Note:** Since the inpu

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