← All problemsSign in

In-tree-active Node Coloring

CodeChefRating 2762Open on judge ↗

**This is an interactive problem.** You are given a tree having $N$ nodes. Each node of this tree is colored either Black or White but you don't know the initial color of any node. You can ask up to $Q$ queries. In each query, you will give a node to the grader. The grader will flip the color of this node and then return the number of edges in the tree connecting nodes of different colors. Note

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