SAISHA AND HER UNIQUE DEMAND
CodeChefOpen on judge ↗
$Saisha$ has a $Tree$ of $N$ nodes. $Edges$ are $weighted$. There are only $two$ types of nodes in the $Tree$: - 1) $Good$ - 2) $Bad$ $She$ wants to $remove$ some edges (possibly zero) such that all the resulting trees contain at max $1$ bad node (i.e 0 or 1 bad node). Her demand is to $remove$ such edges such that $sum$ of $weights$ of $removed$ edges is $minimum$. $Her$
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