Help with DP problem.

Revision en2, by Varun_Shah, 2019-07-15 15:23:46

Given a tree with N nodes we are required to seperate a connected component with exactly k nodes. You are given queries specifying this k. We need to find the minimum edges to be removed for each query.
First line specifies N.
Next N-1 lines specify edges.
Next line shows Q(number of queries).
Subsequent Q lines contain k for each query.

Constraint:
N <= 3000
Q <= 3000
K <= N

Example:
Input:
5
1 2
1 3
1 4
1 5
3
1
2
4

Output:
1
3
1

Tags #tree, #dp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Varun_Shah 2019-07-15 15:23:46 20 Tiny change: 'ach query.\nFirst li' -> 'ach query.<br>\nFirst li'
en1 English Varun_Shah 2019-07-15 15:22:30 688 Initial revision (published)