# Informatics Olympiad All-in-One 1977: [08NOIP Popularization Group] Stereoscopic View

### [Description]

Xiaoyuan is a clever boy, he often tells the children around him what he thinks is interesting. Recently, he is going to explain three-dimensional pictures to children, please help him draw three-dimensional pictures.

Xiaoyuan has a rectangular area with an area of ​​m*n, on which there are m*n grids with a side length of 1, and some building blocks of the same size are piled on each grid (the length, width and height of the building blocks are both 1), Xiaoyuan I would like you to print out a three-dimensional view of these grids. We define each building block as the following format, and will not perform any flip rotation, and will only be placed in one form strictly.

```  +---+
/ / | high
+---+ |
|   | +
| |/width
+---+
long```

Each vertex is represented by a plus sign "+", the length is represented by 3 "-", the width is represented by 1 "/", and the height is represented by two "|". The ASCII codes of the symbols "+", "-", "/", "|" are 43, 45, 47, 124 respectively. The character "." (ASCII code 46) needs to be output as the background, that is, the blank part in the stereogram needs to be replaced with ".". The three-dimensional drawing method follows the following rules:

If two building blocks are adjacent to each other, the diagram is as follows:

```..+---+---+
./   /   /|
+---+---+ |
|   |   | +
|   |   |/.
+---+---+..```

If two building blocks are adjacent up and down, the diagram is as follows:

```..+---+
./   /|
+---+ |
|   | +
|   |/|
+---+ |
|   | +
|   |/.
+---+..```

If two building blocks are adjacent to each other, the diagram is as follows:

```....+---+
.../   /|
..+---+ |
./   /| +
+---+ |/.
|   | +..
|   |/...
+---+....```

In the three-dimensional diagram, define the bottom-left vertex of the first building block (ie, the bottommost building block) above the (m,1)-th grid (ie, the grid at the m-th row and the first column) to be the entire graph The bottom left most point.

### [enter]

The first line has two integers m and n separated by spaces, indicating that there are m*n grids (1<=m, n<=50).

The next m lines are an m*n matrix, each line has n integers separated by spaces, where the integer on the i-th row and j-column indicates how many are stacked on the i-th row and j-column grid Blocks (1<=the number of blocks on each grid<=100).

### [Output]

The stereogram containing the requirements of the title is a character matrix with K rows and L columns, where K and L indicate that at least K rows and L columns are required to output the stereogram as specified.

```3 4
2 2 1 2
2 2 1 1
3 2 1 2```

### [Example of output]

```......+---+---+...+---+
..+---+  /   /|../   /|
./   /|-+---+ |.+---+ |
+---+ |/   /| +-|   | +
|   | +---+ |/+---+ |/|
|   |/   /| +/   /|-+ |
+---+---+ |/+---+ |/| +
|   |   | +-|   | + |/.
|   |   |/  |   |/| +..
+---+---+---+---+ |/...
|   |   |   |   | +....
|   |   |   |   |/.....
+---+---+---+---+......```

AC code:

```#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <iomanip>
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define PDD pair<double,double>
#define x first
#define y second
using namespace std;
const int N=1e3+5,mod=1e9+7;
int a[N][N],h=1000,w=0;
char s[N][N];
char c={
"..+---+",
"./   /|",
"+---+ |",
"|   | +",
"|   |/.",
"+---+.."
};
void init()
{
for(int i=0;i<N;i++)
for(int j=0;j<N;j++)
s[i][j]='.';
}
void push(int x,int y)
{
h=min(h,x-5);
w=max(w,y+6);
x-=5;
for(int i=0;i<6;i++)
for(int j=0;j<7;j++)
if(c[i][j]!='.') s[x+i][y+j]=c[i][j];
}
void pull()
{
for(int i=h;i<=1000;i++)
{
for(int j=0;j<=w;j++)
cout<<s[i][j];
cout<<endl;
}
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
init();
int n,m;
cin>>n>>m;
int mx=0;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
cin>>a[i][j],mx=max(mx,a[i][j]);

for(int i=0;i<n;i++)
for(int j=0;j<=m;j++)
for(int k=1;k<=mx;k++)
{
int x=1000-2*(n-i-1)-(k-1)*3;
int y=4*j+(n-i-1)*2;
if(a[i][j]>=k) push(x,y);
}
pull();
return 0;
}```

Posted by vikaspa on Fri, 24 Feb 2023 09:17:57 +1030