Sonya and Tree
Sonya is a very smart girl, so Danya wants to give her something interesting. He thought about it for a long time and decided that the best gift would be a tree. This tree has $N$ vertices (numbered $1$ through $N$); of course, it is a connected graph with $N-1$ edges connecting those vertices. Danya realised that an ordinary tree probably would not surprise Sonya. Therefore, he decided to plac
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.
Sign in to chat with the tutor and save your progress.
Sign in to start