Tree and its components
CodeChefOpen on judge ↗
Given a tree with $N$ nodes which are numbered as $1$ to $N$ and $N-1$ weighted edges. You can perform 2 types of operation as many times you want: 1: An edge can be broken at a cost of its weight. 2: A coloured node can be made uncoloured or vice versa at a cost of $C_{i}$, where $C_{i}$ is the cost of $i_{th}$ node . A query is defined as $x$ $k$ where you have to find mimimum cost of
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