← All problemsSign in

Tiptoe through the tulips

CodeChefRating 2874Open on judge ↗

Cherry has discovered the Garden of Magical Tulips while going on a walk. The garden can be described as N nodes connected by N-1 trails. The nodes are numbered from 1 to N. Each trail i connects two different nodes, ui and vi and has length Li. It is possible to visit all the nodes starting from any node using a sequence of trails. Magical tulips like to grow alone, without being disturbed. So,

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