시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
14 초 | 512 MB | 31 | 12 | 12 | 63.158% |
Fouad has a raw awesome shawarma, and he is in a city which is represented as an undirected tree. He heard that there is a magical oven that will cook the Shawarma, to make it so delicious. However, In order to acquire the magical oven, there need to be two conditions that should be satisfied in this city:
Please help Fouad to acquire the magical oven, to cook the awesome shawarma by counting in how many ways he can add an edge that satisfies the conditions above.
The first line of the input file contains a single integer T, the number of test cases.
Each test case begins with a line containing three integers N, L, and R (2 ≤ N ≤ 105, 0 ≤ L ≤ R ≤ N −1), in which N is the number of nodes, and L and R are the minimum and maximum numbers of allowed bridges, respectively.
Then N − 1 lines follow, each line contains two integers Xi and Yi (1 ≤ Xi, Yi ≤ N), giving an edge between nodes Xi and Yi.
For each test case, print a single line containing the number of ways to add one new edge such that the number of bridges in the new graph is within the range [L, R] inclusively.
2 5 1 2 1 2 2 3 4 5 2 4 5 1 3 1 2 2 3 4 5 2 4
6 10
A bridge in a graph is an edge, such that if it is removed, the graph will become disconnected.
In the second sample, the result is acquired by connecting an edge between any two different nodes.