RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00330

Mravi

Unrated 레이팅 미적용
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(4^{th}\) round, December \(20^{th}\), 2014
Little Bobi gets up every morning and feeds his favourite pets: ants. He keeps them in a terrarium
with a pipe system that can be represented as a tree with \(N\) nodes. The pipes are represented by the
edges of the tree. The root of the tree is located at node denoted with 1. Inside the pipe system, the
liquid flows from \(a\) node \(to\) its children because of gravity.
We know the flow \(X@@RISE_MATH_BLOCK_0@@i = 30\), and the other \(X\)\(i = 70\). Node 2 is going to get 3.6 liters and node 3 gets 8.4 liters. In the
input data, the sum of flows of pipes going from the same node will always be equal to 100.
Some of Bobi’s pipes aren’t just regular pipes; they are a bit strange. They are super pipes that have
the superpower to squaretheamount of liquid flowing through them. In the previous example, if the
first pipe has the superpower, node 2 gets 12.96 liters and node 3 still gets only 8.4 liters. Notice now
that a node has more liquid leaving it than the amount entering it. This is exactly the reason why
these pipes are super pipes!
All super pipes can have their superpower turned on or offby Bobi.
The ants live only in the leaves of the tree (nodes that don’t have any children). For each leaf we know
the required amount of liquid \(K_{i}\) to feed all ants living in that leaf. Bobi wants to feed his ants by
pouring \(L\) liters of liquid into the root of the tree. He doesn’t have much money so he wants to know
the minimum amount of liters of liquid he needs to buy to keep all of his ants fed.
Please note: The input data is such that the required number \(L\) will not exceed \(2 \cdot 10^{9}\).

제약
입력 형식

The first line of input contains the integer \(N\) (1 ⩽\(N\) ⩽1000).
Each of the following \(N - 1\) lines contain four integers \(A@@RISE_MATH_BLOCK_0@@i\), \(X@@RISE_MATH_BLOCK_1@@i\) (1 ⩽\(A@@RISE_MATH_BLOCK_2@@i\) ⩽100,
0 ⩽\(Ti\) ⩽1) where \(A@@RISE_MATH_BLOCK_3@@i\) are the ends of a pipe (the labels of nodes connected by the pipe), \(X@@RISE_MATH_BLOCK_4@@i\) describing the amount of liquid needed for the ants in the
\(4^{th}\) round, December \(20^{th}\), 2014
\(i\)^{th} node. If the \(i\)^{th} node is not a leaf, \(K\)\(i\) will \(be -1\), otherwise it will be an integer from the interval
[1, 10].

출력 형식

The first and only line of output must contain the required number from the task.
Please note: The allowed absolute error from the correct (precise) solution is 0.001.
SAMPLE TEST DATA
input
input
input
5
1 2 50 0
1 3 50 0
2 4 25 0
2 5 75 1
-\(1 -1\ 4\ 1\ 9\)
3
1 2 20 1
1 3 80 1
-1 4 8
6
1 2 100 1
2 3 20 0
2 4 20 0
2 5 60 0
4 6 100 1
-\(1 -1\ 1 -1\ 1\ 2\)
output
output
output
8.00
10.0000
2.659
Clarification of the first example: If Bobi pours 8 liters of liquid into the root of the tree, node 3 will get 4
liters, node 4 will get 1 liter and node 5 will get 9 liters. These nodes are leaves (they have ants in them) and
this is the exact minimum amount the ants need to get. Also, 8 liters is the minimum amount of liquid that
satisfies the “ant” conditions.

예제 1
입력
5
1 2 50 0
1 3 50 0
2 4 25 0
2 5 75 1
-1 -1 4 1 9
출력
8.00
예제 2
입력
3
1 2 20 1
1 3 80 1
-1 4 8
출력
10.0000
예제 3
입력
6
1 2 100 1
2 3 20 0
2 4 20 0
2 5 60 0
4 6 100 1
-1 -1 1 -1 1 2
출력
2.659
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2014/2015 Contest 4

평가 및 의견

Mravi

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Mravi

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8