Tree Obsession
You will be given as input a tree consisting of N nodes, and a cost matrix C of size H x H. The matrix has the property that C(i, j) = C(j, i) and C(i, i) = 0. Chef is going to ask you Q queries now. In each query, you will be given a set S of k vertices. Say S = {V1, V2 ... Vk}. You will also be given a positive integer X. Your task is to find the minimum cost of a subset T of vertices of size
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