Logo
(追記) (追記ここまで)

18704번 - Awesome Shawarma 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
14 초 512 MB90302342.593%

문제

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:

  • One extra edge that must be added to join two different nodes in the tree (It is allowed to join two nodes, which were previously connected by a direct edge).
  • The number of bridges after adding the new edge should be between [L, R] inclusively.

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.

제한

예제 입력 1

2
5 1 2
1 2
2 3
4 5
2 4
5 1 3
1 2
2 3
4 5
2 4

예제 출력 1

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.

출처

ICPC > Regionals > Africa and Arab > Arab Collegiate Programming Contest > 2018 Arab Collegiate Programming Contest A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /