All submissions for this problem are available.You are given a tree with $N$ nodes, which are numbered from $1$ to $N$. It is rooted at Node $1$. We define a single $operation$ as follows :- - Put a chip on the root. - Within an operation, you can "move" as many times as you like. - A move is defined as picking a node which has a chip on it and then removing the chip from that node and placing a chip on all of its children. A node is covered if it has at least $1$ chip placed on it. You can do at most $K$ operations. What is the maximum number of covered nodes that you can obtain? Note that there is no constraint on the amount of chips placed on any node. ###Input: - The input contains a single integer, $T$, which denotes the number of testcases. - The first line of each testcase will contain two integers, $N$ and $K$, denoting the number of nodes and operations allowed, respectively. - The next $N-1$ lines contain two integers $u$ and $v$ indicating that there is an edge between nodes $u$ and $v$ in the tree. ###Output: - The output should consist of $T$ integers printed on separate lines. The integer on the i-th line should be the maximum number of nodes which can be covered in that testcase. ###Constraints - $1 \leq T \leq 5$ - $2 \leq N \leq 5*10^5$ - $1 \leq K \leq N$ - Sum of $N$ over all testcases $ \leq 5*10^5$ - $1 \leq u,v \leq N$ - The given graph is a tree ###Subtasks - 30 points : Sum of $N$ of over all testcases $ \leq 5000 $ - 70 points : Original Constraints. ###Sample Input: ``` 1 7 2 1 2 1 3 2 4 2 5 3 6 3 7 ``` ###Sample Output: ``` 6 ``` ###Explanation: You can cover nodes 4,5,6,7 in the first operation and 2,3 in the second. 2,3 for example can be covered by placing the chip on the root and then moving it to its children.
|Tags||expp2019, shashwatchandr, tree|
|Time Limit:||1.5 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.