#P9456. Three-View Projection of Cubes
Three-View Projection of Cubes
Three-View Projection of Cubes
Given a rectangular region with dimensions $n\,cm$, $m\,cm$, and $k\,cm$ along the $x$, $y$, and $z$ axes respectively, the region is divided into $n \times m \times k$ cells. A cell located at position $(x, y, z)$ denotes the $x$-th cell from left to right, the $y$-th cell from front to back, and the $z$-th cell from bottom to top. In some of these cells, a small cube of side length $1\,cm$ is placed.
The three-view projection of this 3D arrangement consists of:
- Top view: The projection seen from above (i.e. looking downward along the $z$-axis). Its plane is the $x$-$y$ plane. A cell in the top view is marked as 1 if there exists at least one cube (for any $z$) at that $(x,y)$ position; otherwise, it is 0. The top view is presented as a matrix with $m$ rows and $n$ columns, where the first row corresponds to $y=1$ (the front) and the last row corresponds to $y=m$ (the back).
- Left view: The projection seen from the left side (along the positive $x$-axis, looking from left to right). Its plane is the $y$-$z$ plane. A cell is marked 1 if there is a cube with the corresponding $(y,z)$ (for any $x$) and 0 otherwise. The view is printed as a matrix with $k$ rows and $m$ columns. Here, the first row corresponds to $z=k$ (top) and the last row corresponds to $z=1$ (bottom).
- Front view: The projection seen from the front (looking from front to back along the $y$-axis). Its plane is the $x$-$z$ plane. A cell is marked 1 if there exists a cube with the corresponding $(x,z)$ (for any $y$) and 0 otherwise. This view is printed as a matrix with $k$ rows and $n$ columns, with the first row representing $z=k$ (top) and the last row representing $z=1$ (bottom).
Output the three views in the order: Top view, then Left view, then Front view. Separate each view by an empty line.
inputFormat
The first line of input contains three integers $n$, $m$, and $k$ ($1 \le n, m, k \le 100$) representing the sizes along the $x$, $y$, and $z$ axes respectively. The next line contains an integer $T$ representing the number of cubes placed in the region.
Each of the following $T$ lines contains three integers $x$, $y$, and $z$ ($1 \le x \le n$, $1 \le y \le m$, $1 \le z \le k$), which denote the position of a cube.
outputFormat
Output the three views of the region:
- Top view: Print $m$ lines, each line is a string of length $n$. The $j$-th character in the $i$-th line (considering $i$ from 1 to $m$) is '1' if there is at least one cube at position $(j, i)$ (for some $z$), otherwise '0'.
- Left view: Print $k$ lines, each line is a string of length $m$. The first printed line corresponds to $z=k$ and the last to $z=1$. The $j$-th character in a line is '1' if there is at least one cube at that $(y, z)$ position (for some $x$), otherwise '0'.
- Front view: Print $k$ lines, each line is a string of length $n$. The first line corresponds to $z=k$ and the last to $z=1$. The $j$-th character is '1' if there is at least one cube at that $(x, z)$ position (for some $y$), otherwise '0'.
Separate each view by an empty line.
sample
3 3 3
5
1 1 1
1 1 2
2 3 2
3 3 2
2 2 3
100
010
011
010
101
100
010
111
100
</p>