Tuco meets Heisenberg
CodeChefOpen on judge ↗
Tuco, the gangster has got bags of meth from Heisenberg. Before giving him money, he asks Heisenberg to solve a problem. As Heisenberg is weak at coding, can you help him get his money. You are given an undirected tree of N nodes rooted at 1. You need to find the sum of special function F(x) for each node x (1 ≤ x ≤ N). Let y be any node in the subtree of node x such that path from x to y is a s
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