#P9456. [入门赛 #14] Three-View Projection (Hard Version)
[入门赛 #14] Three-View Projection (Hard Version)
Problem Description
All content related to the axes/directions in this problem is based on the following axes, positions, and viewing direction. The observer stands at the position shown in the figure and is looking toward the positive direction of the axis (the green line) (the arrow direction).
Now there is a cuboid region with length, width, and height (the lengths extended along the axes) of , , and . We divide this region into small cells. In each small cell, you may place a small cube with side length .
We use an integer triple to represent the position of a cell in space: it means the -th cell from left to right, the -th cell from front to back, and the -th cell from bottom to top.

For example, in the region shown above, according to the observer’s position, we can see that the face containing the red and blue lines (the axes) is the front face, the face containing the blue and green lines (the axes) is the left face, and the face containing the red and green lines (the axes) is the bottom face. The five cubes are located at , , , , .
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 lines.
The first line contains three integers , representing the length, width, and height of the cuboid region.
Next come lines, each containing integers. Split them into groups of lines each. In the -th group, the -th line (i.e., line ), the integer in the -th column is , which represents the cell at . If , it means there is a small cube in that cell; otherwise, there is no cube in that cell.
Output Format
Output a total of lines.
The first lines each contain integers, representing the front view from top to bottom, from left to right. If a position in the front view is filled, output , otherwise output . Separate adjacent integers in the same line by one space.
The next lines each contain integers, representing the left view from top to bottom, from back to front. If a position in the left view is filled, output , otherwise output . Separate adjacent integers in the same line by one space.
The next lines each contain integers, representing the top view from back to front, from left to right. If a position in the top view is filled, output , otherwise output . 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 of the testdata, it is guaranteed that and 。
Translated by ChatGPT 5
