Programming contests

DEIK Regionális Programozó Csapatverseny, egyetemi/főiskolai kategória, 2017. december 3.

December 3, 2017, 10:10 AM – December 3, 2017, 3:10 PM

C — Piles of Dice

In this problem, you have to create a graphical spatial view of a pile of dice using ASCII characters. The dice are arranged in m rows and n columns and are stacked on top of each other, forming towers. Rows are numbered from 1 to m, row 1 being the most far-off, row m being the closest in the graphical view. Columns are numbered from 1 to n, from left to right. Some dice may cover others, so they can be partially or entirely hidden in the view. The following figure illustrates the view of a single die in 6 rows and 7 columns using the characters '+' (plus), '-' (hyphen), '|' (vertical bar), '/' (forward slash) and ' ' (space):

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

Write a program that creates the graphical spatial view of a pile of dice based on its description, in the fewest possible rows and columns. Use the '.' (dot) character to represent places not covered by dice.

Input Specification

The first line of the input contains two positive integers m and n (1 ≤ mn ≤ 50). Each of the next m lines consists of n positive integers less than or equal to 50, indicating the heights of the dice towers in each position.

Output Specification

Your program should output the graphical spatial view of the pile of dice according to the above instructions in the minimum required area.

Sample Input 1

  1. 1 2
  2. 1 2
download as text file

Output for Sample Input 1

  1. ......+---+
  2. ...../   /|
  3. ....+---+ |
  4. ..+-|   | +
  5. ./  |   |/|
  6. +---+---+ |
  7. |   |   | +
  8. |   |   |/.
  9. +---+---+..
download as text file

Sample Input 2

  1. 3 1
  2. 2
  3. 1
  4. 3
download as text file

Output for Sample Input 2

  1. ......+---+
  2. ..+---+  /|
  3. ./   /|-+ |
  4. +---+ | | +
  5. |   | + |/|
  6. |   |/|-+ |
  7. +---+ |/| +
  8. |   | + |/.
  9. |   |/| +..
  10. +---+ |/...
  11. |   | +....
  12. |   |/.....
  13. +---+......
download as text file

Sample Input 3

  1. 2 3
  2. 2 3 2
  3. 1 2 1
download as text file

Output for Sample Input 3

  1. ........+---+....
  2. ......./   /|....
  3. ......+---+ |....
  4. ....+-|   | +---+
  5. .../  |   |/   /|
  6. ..+---+---+---+ |
  7. ..|  /   /|   | +
  8. ..| +---+ |   |/|
  9. ..+-|   | +---+ |
  10. ./  |   |/   /| +
  11. +---+---+---+ |/.
  12. |   |   |   | +..
  13. |   |   |   |/...
  14. +---+---+---+....
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024