← All problemsSign in

Black and White Tree

CodeChefRating 2808Open on judge ↗

Chef has a rooted tree, consisting of N vertexes. Each tree vertex has a unique index (integer from 1 to N), and also has a color (black or white). The root of Chef's tree has index 1. Initially, all vertexes of the tree are colored white. Then Chef start playing with the tree. He writes out a sequence of M vertexes of the tree V1, V2, ..., VM. And now he wants to make M operations with the tree,

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