← All problemsSign in

Amazing Experiment

CodeChefRating 2540Open on judge ↗

Dr.Zero lives in Treeland. Tree land consists of a tree with N nodes connected by N-1 weighted undirected edges. The nodes of the tree are numbered from 1 to N. The tree is rooted at node 1. Dr. Zero wanted to create a super amazing experiment. Before starting the experiment, he has laid out few important definitions needed. - A subtree rooted at node x is defined recursively. It contains node x

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