#P9456. [入门赛 #14] Three-View Projection (Hard Version)

[入门赛 #14] Three-View Projection (Hard Version)

Problem Description

All content related to the x,y,zx, y, z axes/directions in this problem is based on the following x,y,zx, y, z axes, positions, and viewing direction. The observer stands at the position shown in the figure and is looking toward the positive direction of the yy axis (the green line) (the arrow direction).

Now there is a cuboid region with length, width, and height (the lengths extended along the x,y,zx, y, z axes) of n cmn \text{ cm}, m cmm \text{ cm}, and k cmk \text{ cm}. We divide this region into n×m×kn \times m \times k small cells. In each small cell, you may place a small cube with side length 1 cm1 \text{ cm}.

We use an integer triple (x,y,z)(x, y, z) to represent the position of a cell in space: it means the xx-th cell from left to right, the yy-th cell from front to back, and the zz-th cell from bottom to top.

For example, in the 3×3×33 \times 3 \times 3 region shown above, according to the observer’s position, we can see that the face containing the red and blue lines (the x,zx, z axes) is the front face, the face containing the blue and green lines (the y,zy, z axes) is the left face, and the face containing the red and green lines (the x,yx, y axes) is the bottom face. The five cubes are located at (1,1,1)(1, 1, 1), (1,1,2)(1, 1, 2), (2,3,2)(2, 3, 2), (3,3,2)(3, 3, 2), (2,2,3)(2, 2, 3).

A three-view drawing is obtained by observing the same 3D object from three different angles: from the top (top to bottom), from the left (left to right), and from the front (front to back).

For example, the above are the three-view drawings of the sample region.

Now, given a region and the placement of cubes in it, please help compute the three-view projections of this region.

Input Format

The input has a total of n×k+1n \times k + 1 lines.

The first line contains three integers n,m,kn, m, k, representing the length, width, and height of the cuboid region.
Next come n×kn \times k lines, each containing mm integers. Split them into groups of nn lines each. In the xx-th group, the yy-th line (i.e., line (x1)×n+y(x - 1) \times n + y), the integer in the zz-th column is ax,y,za _ {x, y, z}, which represents the cell at (y,z,x)(y, z, x). If ax,y,z=1a _ {x, y, z} = 1, it means there is a small cube in that cell; otherwise, there is no cube in that cell.

Output Format

Output a total of 2k+m2k + m lines.

The first kk lines each contain nn integers, representing the front view from top to bottom, from left to right. If a position in the front view is filled, output 11, otherwise output 00. Separate adjacent integers in the same line by one space.
The next kk lines each contain mm integers, representing the left view from top to bottom, from back to front. If a position in the left view is filled, output 11, otherwise output 00. Separate adjacent integers in the same line by one space.
The next mm lines each contain nn integers, representing the top view from back to front, from left to right. If a position in the top view is filled, output 11, otherwise output 00. Separate adjacent integers in the same line by one space.

All directions above are based on the observer’s initial standing position and facing direction. If you are confused about the output order, please refer to the sample to help understand.

3 3 3
1 0 0
0 0 0
0 0 0
1 0 0
0 0 1
0 0 1
0 0 0
0 1 0
0 0 0
0 1 0
1 1 1
1 0 0
0 1 0
1 0 1
0 0 1
0 1 1
0 1 0
1 0 0
4 6 3
0 0 0 0 0 1
0 0 0 0 0 1
0 0 1 0 0 0
0 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 1
0 0 0 0 0 0
1 0 0 0 0 1
0 0 0 0 0 0
0 1 0 0 1 0
0 0 0 0 0 1
1 0 0 0 0 1
0 1 1 1
1 1 0 1
1 1 1 0
1 1 0 0 1 1
1 0 0 1 1 1
1 0 0 1 0 0
1 1 1 1
0 1 0 0
0 0 0 0
0 1 1 0
1 1 0 0
0 0 0 1

Hint

Sample 1 Explanation

Sample 1 is exactly the example shown in the statement.

Constraints

For 100%100\% of the testdata, it is guaranteed that 1n,m,k2001 \leq n, m, k \leq 200 and 0ax,y,z10 \leq a _ {x, y, z} \leq 1

Translated by ChatGPT 5