← All problemsSign in

Sonya and Gifts

CodeChefRating 2698Open on judge ↗

Sonya lives in a magical land which consists of $N$ cities (numbered $1$ through $N$) and $N - 1$ roads connecting them. In other words, the country where Sonya lives is a tree. The country is magical because toys of an infinite number of types are made there. The types of toys are labeled by all integers and in each city, there is a toy store which sells an infinite number of toys of each type

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