Canadian Computing Competition: 2000 Stage 1, Junior #4, Senior #2
A series of streams run down the side of a mountain. The mountainside is very rocky so the streams split and rejoin many times. At the foot of the mountain, several streams emerge as rivers. Your job is to compute how much water flows in each river.
At any given elevation there are
Input Specification
The first line of input contains
- a line containing
99
(to indicate a split) - a line containing an integer, the number of the stream that is split
- a line containing an integer between
and , the percentage of flow from the split stream that flows to the left fork. (The rest flows to the right fork)
For each join location, there will be two lines of input:
- a line containing
88
(to indicate a join) - a line containing an integer, the number of the stream that is rejoined with the stream to its right
The flow from both joined streams is combined. After the last split or join location will be:
- a single line containing
77
(to indicate end of input)
Output Specification
Your job is to determine how many streams emerge at the foot of the mountain and what the flow is in each. Your output is a sequence of real numbers, rounded to the nearest integer, giving the flow in rivers
Sample Input
3
10
20
30
99
1
50
88
3
88
2
77
Sample Output
5 55
Comments
Hello. So, I pass the first 4 test cases but bomb on the 5th. (I also pass the test case given by Compro72 below.) Is there a mod who can help me understand what my error is?
i am getting index error at 4th and 5th case, can the mod check and help me understand the error
Try this case:
It should output:
are we at the top of the mountain or the bottom of the mountain
This comment is hidden due to too much negative feedback. Show it anyway.
Thank you for your dislikes -)) I was hoping that this point would simply be explained to me. I thought that if the outermost thread is being merged, then nothing happens. After that, I was able to correct my code and it successfully passed all tests.
When splitting or merging, left and right is based on your view of the mountain (i.e., the direction is not relative to the split).