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

19185번 - Bus Lines 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.75 초 64 MB327541.667%

문제

There are $(n - 1)$ bidirectional streets connecting $n$ crossroads (numbered 1ドル$ to $n$) in Byteozavodsk. There is only one way to travel between every pair of crossroads without going through any street more than once.

You are tasked with planning city's bus line routes. A bus line route starts and ends at a crossroad such that there is only one street that is incident with this crossroad. The starting crossroad must be different from the ending one.

Every street has a capacity: the number of bus lines that can pass through this street.

Calculate the maximum possible number of bus lines that can be arranged in Byteozavodsk. Not that it makes any sense, but there can be two bus lines that are connecting exactly the same pair of crossroads.

입력

The first line contains one integer $z,ドル the number of test cases. Then $z$ test cases are described in the following way.

The first line of each test case description contains one integer $n$ (2ドル \leq n \leq 10^5$), the number of crossroads in Byteozavodsk. Each of the following $(n - 1)$ lines describing city streets contains three integers $a,ドル $b,ドル $c$ (1ドル \leq a, b \leq n,ドル $a \neq b,ドル 1ドル \leq c \leq 10^6$) meaning that a particular street connects crossroad $a$ with crossroad $b,ドル and has a capacity of $c$.

출력

For each test case, output a single line containing one integer: the maximum number of bus lines that can be arranged in Byteozavodsk.

제한

예제 입력 1

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

예제 출력 1

3
2
1

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2015 > Day 6: Jagiellonian U Contest G번

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

출처

대학교 대회

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

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