OpenJudge

08:World Construction

总时间限制:
1000ms
内存限制:
65536kB
描述

Rainbow has got some strange words made of numbers、’(’、’)’、’:’、’.’、’[’、’]’, and he guesses it is Maya's secret to build the world. He decides to use this line of characters to build a two-dimensional world.

This two-dimensional world is made of rectangular areas. The four corners of the rectangular area are denoted by '+', the horizontal boundary is denoted by '-', the boundary in the vertical direction is denoted by '|', and the interior is filled with spaces. Each rectangle consists of an integer between 0 and 9999 indicating the identity of the owner of the area. The world's construction rules he imagines are as follows:

Number:
A number is a valid expression, which represents arectangular area. The minimum height inside this region is 1, and the minimum width of this region is this number's digit number +2. This number is written in the first row of the area, 1 character from the left border. For example, the rectangular area represented by 566 is:

+-----+

| 566 |

+-----+

Colon and dot:
The expressions connected by colons and dots are at the same level. The colon indicates that the positional relationship between the regions represented by the expressions is vertical. The dot indicates that the positional relationship between the regions represented by the expressions is horizontal.

Parentheses:
When a number of expressions are enclosed in a pair of parentheses, it is treated as one expression. The expressions enclosed in parentheses and the expressions outside the brackets are at different levels, but if the expressions enclosed in parentheses and the expressions outside the brackets are connected with colons or dots, they are at the same level. The expressions with the same level that are connected with colon or dot must be enclosed in a pair of parentheses. It is not allowed that there exist both colon and dot in the expressions at the same level.

Square brackets:
Square brackets can only enclose one expression. In a group of expressions at the same level, there can only be at most one expression which is enclosed in square brackets. An area represented by a set of expressions at the same level should have the same size. However, the expression enclosed insquare brackets is a special case whose width (or height, depending on the connection character) is three times the size of expression at same level.


Can you help Rainbow draw this world?



输入
A string made of numbers、’(’、’)’、’:’、’.’、’[’、’]’. The input length does not exceed 255 and the total output length does not exceed 100000 bytes.
输出
Some rectangular areas, as described above. See specific examples.
样例输入
((566:[30]).1.239)
样例输出
+-----+-----+-----+
| 566 | 1   | 239 |
+-----+     |     |
| 30  |     |     |
|     |     |     |
|     |     |     |
+-----+-----+-----+
提示
566 and [30] are the same level expression, 566 area's internal width is 5, height is 1, both are the minimum. [30] area's height is 3 times of the height of 566 area, with same width.
(566: [30]), 1,239 are the same level expressions. The internal height of the (566: 30) area can no longer be less than 5, so the width and height of the region 1 and 239 can only be 5, same as (566: 30).

01 Use "long long" to calculate the answer
05 Expected Value of an Expression: Ai is less than 2^20

全局题号
15301
提交次数
0
尝试人数
0
通过人数
0