### 2000 Canadian Computing Competition, Stage 1

## Problem S2: Babbling Brooks

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 m streams, labelled 1 to m from left-to-right. As we proceed down the mountainside, one of the streams may split into a left fork and a right fork, increasing the total number of streams by 1, or two streams may rejoin, reducing the total number of streams by 1. After a split or a rejoining occurs, the streams are renumbered consecutively from left-to-right. There is always at least one stream and there are never more than 100 streams.

### Input

The first line of input contains n, the initial number of streams at some high altitude. The next n lines give the flow in each of the streams from left-to-right. Proceeding down the mountainside, several split or rejoin locations are encountered. For each split location, there will be three lines of input.

- a line containing 99 (to indicate a split)
- a line containing the number of the stream that is split
- a line containing a number between 0 and 100, 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 the number of the stream that is rejoined with the stream to its right

### Output

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 1 through m.

### Sample Input

3 10 20 30 99 1 50 88 3 88 2 77

### Sample Output

5 55

All Submissions

Best Solutions

**Point Value:** 7

**Time Limit:** 2.00s

**Memory Limit:** 16M

**Added:** Sep 29, 2008

**Problem Types:**[Show]

**Languages Allowed:**

C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

P234reron Nov 16, 2016 - 2:44:42 am UTC Case 5jargonon Nov 16, 2016 - 7:11:16 pm UTC Re: Case 5xiaowuc1on May 23, 2014 - 11:30:10 pm UTCI might also be misunderstanding the problem statement - a few concerns I have:

1) What happens if there are fewer than N streams? (Sample output appears to address this case, only print out flows for all existent streams.)

2) Can a stream have flow of zero? (Test case 5 seems to imply that you just have a flow of zero.)

3) Are there rounding issues? (Probably not? My output does not appear to be on a rounding boundary.)

EDIT: I claim that this problem statement is confusing. I downloaded the judge test data and realized that the number of streams in test case 2 is larger than the starting number of streams, so the term "n" is overloaded (you'll note this given my first question). In any event, once I print out all streams, I get AC.

jargonon May 27, 2014 - 12:37:29 am UTC Re: ...zhxl0903on Dec 24, 2008 - 6:42:51 pm UTCSourSpinachon May 14, 2009 - 11:51:42 pm UTC Re: hmm...Bryanon May 14, 2009 - 8:05:19 pm UTC wats wrong?hansonw1on May 14, 2009 - 9:06:29 pm UTC Re: wats wrong?Bryanon May 14, 2009 - 9:11:08 pm UTC Re: Re: wats wrong?