MIKE AND COMPRESSION
CodeChefOpen on judge ↗
Mike has a rooted tree, T. He wants to compress this tree such that every node is connected to root node. He can do this by applying following operations any number of times: - Choose 2 nodes, u(u!=1) and v, of tree T. - Remove the edge between the node u and its parent and add the edge between node v and node u. - Add level[u] - level[v] - 1 to the cost, where level[x] = depth of node x. Mike
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