#P1058. [NOIP 2008 普及组] 立体图

    ID: 58 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>模拟字符串2008NOIp 普及组枚举,暴力

[NOIP 2008 普及组] 立体图

Description

Xiao Yuan is a smart kid who often tells his friends things he finds interesting. Recently, he plans to explain 3D diagrams to them and asks you to draw the 3D diagram.

Xiao Yuan has a rectangular area of size m×nm \times n consisting of m×nm \times n unit squares. On each square, some identical blocks are stacked (each block has length, width, and height all equal to 11). He wants you to print the 3D diagram of these squares. Each block is defined in the following format, and there is no flipping or rotation; blocks are placed strictly in this single orientation:

$$\def\arraystretch{1e-10} \begin{aligned} &\verb! +---+!\\ &\verb! / /|!\\ &\verb!+---+ |!\quad\textsf{高}\\ &\verb!| | +!\\ &\verb!| |/ !\quad\textsf{宽}\\ &\verb!+---+ !\\ & \quad\textsf{长} \end{aligned}$$

Each vertex is represented by one plus sign +, the length by three -, the width by one /, and the height by two |. The ASCII codes of characters +, -, /, | are 4343, 4545, 4747, 124124, respectively. The character . (ASCII code 4646) must be printed as the background; that is, blank areas in the 3D diagram should be filled with .. The drawing rules are as follows:

If two blocks are adjacent horizontally (left-right), they look like:

$$\def\arraystretch{1e-10} \begin{aligned} \verb!..+---+---+!\\ \verb!./ / /|!\\ \verb!+---+---+ |!\\ \verb!| | | +!\\ \verb!| | |/.!\\ \verb!+---+---+..!\\ \end{aligned}$$

If two blocks are adjacent vertically (up-down), they look like:

$$\def\arraystretch{1e-10} \begin{aligned} \verb!..+---+!\\ \verb!./ /|!\\ \verb!+---+ |!\\ \verb!| | +!\\ \verb!| |/|!\\ \verb!+---+ |!\\ \verb!| | +!\\ \verb!| |/.!\\ \verb!+---+..!\\ \end{aligned}$$

If two blocks are adjacent front-to-back, they look like:

$$\def\arraystretch{1e-10} \begin{aligned} \verb!....+---+!\\ \verb!.../ /|!\\ \verb!..+---+ |!\\ \verb!./ /| +!\\ \verb!+---+ |/.!\\ \verb!| | +..!\\ \verb!| |/...!\\ \verb!+---+....!\\ \end{aligned}$$

In the 3D diagram, define the lower-left corner vertex of the bottom-most block on the square at (m,1)(m, 1) (i.e., row mm, column 11) as the lower-left corner of the entire diagram.

Input Format

The first line contains two integers mm and nn separated by a space, indicating there are m×nm \times n squares (1m,n501 \le m, n \le 50).

The next mm lines give an m×nm \times n matrix. Each line contains nn integers separated by spaces; the integer at row ii, column jj is the number of blocks stacked on that square (11 \le the number of blocks on each cell 100\le 100).

Output Format

Output the required 3D diagram as a KK-row by LL-column character matrix, where KK and LL are the minimal numbers of rows and columns needed to print the diagram according to the rules.

3 4
2 2 1 2
2 2 1 1
3 2 1 2

......+---+---+...+---+
..+---+  /   /|../   /|
./   /|-+---+ |.+---+ |
+---+ |/   /| +-|   | +
|   | +---+ |/+---+ |/|
|   |/   /| +/   /|-+ |
+---+---+ |/+---+ |/| +
|   |   | +-|   | + |/.
|   |   |/  |   |/| +..
+---+---+---+---+ |/...
|   |   |   |   | +....
|   |   |   |   |/.....
+---+---+---+---+......

Hint

NOIP 2008 Junior, Problem 4.

Translated by ChatGPT 5