← All problemsSign in

Tree of Trees

CodeChefRating 2266Open on judge ↗

You are given $N$ edge-weighted trees $T_1, T_2,\ldots, T_N$ having $M_1, M_2,\ldots ,M_N$ nodes respectively. You also have an array $A$ of $N-1$ positive integers. You need to connect these $N$ trees using $N-1$ edges such that each of these edges have weights equal to $A_i$ for some $i \in [1,N-1]$ and each of the $A_i$ must be used exactly once. Note that after connecting these edges, a singl

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