Help with DP problem.

Правка en1, от Varun_Shah, 2019-07-15 15:22:30

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

Теги #tree, #dp

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Varun_Shah 2019-07-15 15:23:46 20 Tiny change: 'ach query.\nFirst li' -> 'ach query.<br>\nFirst li'
en1 Английский Varun_Shah 2019-07-15 15:22:30 688 Initial revision (published)