Advanced ASCII Cubes
Time limit1sMemory limit128 MB
Render stacked cubes on an N by M grid as ASCII art using isometric projection, minimizing output lines and width.
- Level
Medium4 of 10
- Topics
- Implementation, Simulation, Matrix
- Solved
- No attempts yet
Problem
The table surface is divided into an grid of square cells. Over some cells, cubes are stacked one on top of another to form towers. For each cell, the number of cubes stacked over it is given by the matrix .
Your program must render the view of the table in ASCII graphics, where each cube is drawn as shown below:
+---+
/ /|
+---+ |
| | +
| |/
+---+
(the characters used are +, -, /, |, whose ASCII codes are 43, 45, 47, 124). Use the dot . (ASCII 46) as the background.
Input
The input contains the integers and , followed by the matrix given row by row. The first row describes the towers of cubes farthest from the viewer, from left to right; the last row describes the towers nearest to the viewer.
Output
Output the ASCII view of the table using the minimal number of lines needed to show all cubes. Every line must have the same length, equal to the minimal width needed to show all cubes.