0 人解决,2 人已尝试。
0 份提交通过,共有 11 份提交。
9.9 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
Write a program which:
reads the description of a series-parallel circuit,
computes the minimal number of connections that must run on the top side of the board,
writes the result.
From the standard input one should read the description of a series-parallel circuit. The description is in a recursive form:
1.if the first line of the description contains a capital letter S and a positive integer n (2 <= n <= 10000) separated from each other by a single space, then the circuit being described consists of n smaller circuits connected in series; they are described in the successive lines,
2.if the first line of the description contains a capital letter R and a positive integer n (2 <= n <= 10000) separated from each other by a single space, then the circuit being described consists of n smaller circuits connected in parallel (by means of two branching units); they are described in the successive lines,
3.a line containing only one capital letter X describes a circuit consisting of a single unit only.
The total number of letters X occurring in the description of a circuit does not exceed 10000000, and the recursive depth of the description does not exceed 500.
Your program should write to the standard output. In the first line there should be one integer equal to the minimal number of connections that must run on the top side of the board.
R 3 S 2 X R 2 S 2 X X S 2 X X S 3 X X X R 2 X X
8 hint:
0 人解决,2 人已尝试。
0 份提交通过,共有 11 份提交。
9.9 EMB 奖励。