Preparando MOJI
Two players, Red and Blue, are at it again, and this time they're playing with crayons! The mischievous duo is now vandalizing a rooted tree, by coloring the nodes while playing their favorite game.
The game works as follows: there is a tree of size $$$n$$$, rooted at node $$$1$$$, where each node is initially white. Red and Blue get one turn each. Red goes first.
In Red's turn, he can do the following operation any number of times:
Then, it's Blue's turn. Blue can do the following operation any number of times:
After the two turns, the score of the game is determined as follows: let $$$w$$$ be the number of white nodes, $$$r$$$ be the number of red nodes, and $$$b$$$ be the number of blue nodes. The score of the game is $$$w \cdot (r - b)$$$.
Red wants to maximize this score, and Blue wants to minimize it. If both players play optimally, what will the final score of the game be?
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$1 \le k \le n$$$) — the number of vertices in the tree and the maximum number of red nodes.
Next $$$n - 1$$$ lines contains description of edges. The $$$i$$$-th line contains two space separated integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$; $$$u_i \neq v_i$$$) — the $$$i$$$-th edge of the tree.
It's guaranteed that given edges form a tree.
Print one integer — the resulting score if both Red and Blue play optimally.
4 2 1 2 1 3 1 4
1
5 2 1 2 2 3 3 4 4 5
6
7 2 1 2 1 3 4 2 3 5 6 3 6 7
4
4 1 1 2 1 3 1 4
-1
In the first test case, the optimal strategy is as follows:
In the second test case, the optimal strategy is as follows:
For the third test case:
The score of the game is $$$4 \cdot (2 - 1) = 4$$$.