← All problemsSign in

RGB Construction

CodeChefRating 2256Open on judge ↗

Chef's friend JJ challenged him to construct a tree which has exactly $R$ red coloured nodes, $G$ green coloured nodes and $B$ blue coloured nodes. To make the task interesting he added an extra condition: the simple path between any two blue nodes should contain **at least** one red node and **at least** one green node. Can you help Chef to complete JJ's challenge by constructing any valid 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