← All problemsSign in

Alternating Diameter

CodeChefRating 2300Open on judge ↗

Chef stumbled upon $B$ black nodes and $W$ white nodes and now wants to construct a tree using them. Chef is bamboozled by the total number of trees that can be constructed using these nodes. To reduce this count, Chef considered only those trees which have **at least** one diameter that has alternating colors i.e. a black node is followed by a white node and a white node is followed by a black n

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