#P3326. [SDOI2015] 立体图
[SDOI2015] 立体图
Description
Xiaoyuan (pinyin) is a smart kid who often explains things he finds interesting to the children around him. Recently, he plans to explain stereograms under colored horizontal light sources to the kids and asks you to help draw them on a plane.
Xiaoyuan has a rectangular area of size with unit squares, each of side length . On each square, some identical blocks are stacked (each block has length, width, and height all equal to ).
For convenience, assume this area faces south with north at the top. Below is an example.

Xiaoyuan wants you to print the stereogram of these squares. We define each block in the following fixed format, and it will never be flipped or rotated; it is always placed strictly in this single orientation (the left side shows the pattern to be printed, and the right side shows the decimal ASCII for each position; ASCII is a space).

Under good optical conditions, Xiaoyuan shines beams of parallel light on these blocks simultaneously. These parallel lights satisfy: each is one of the three primary colors red, green, or blue; the angles with the -axis and -axis are multiples of ; and the angle with the positive -axis is either , , or .
Specifically, we consider at most different directions of parallel light. Their incident directions can be described as: northwest with elevation, due north with elevation, northeast with elevation, due west with elevation, vertical incidence from above, due east with elevation, southwest with elevation, due south with elevation, and southeast with elevation. For each unit block, the three printable faces are divided into small triangles.

The three primary colors red, green, and blue are represented by the letters R, G, and B. The three secondary colors after double overlap, cyan, yellow, and purple, are represented by C, Y, and P, respectively. For triple overlap, i.e., white, use W.
Input Format
The first line contains two positive integers , meaning the area has rows and columns. Then lines follow, describing each row from far to near in order. Each line gives positive integers, indicating how many blocks are stacked at cell .
Then there are lines, each with three characters, describing the colors of light in the corresponding directions (same directional order as described on the map). Each character is either one of RGB, indicating the corresponding color, or *, indicating no incident light. The nine directions, in order, are: northwest with elevation, due north with elevation, northeast with elevation, due west with elevation, vertical incidence from above, due east with elevation, southwest with elevation, due south with elevation, and southeast with elevation.
Output Format
Output the rendered result. The output must not contain a leading blank line, and there must be no extra blank line at the end. The first column must not be all spaces, and there must be no trailing spaces at the end of any line.
2 2
2 1
1 1
R**
***
**G
+-------+
/Y\YYYY'/|
/YY.*'YY/G|
/.YYYY\Y/G/|
+-------+G.G|
|\GGGGG/|\:G|
|G\GGG/G|G*G|
|GG\G/GG|G:\|
|G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/|C:\|/
+-------+-------+-------+-------+C.C|C'C+
|\YYYYY/|\YYYYY/|\YYYYY/|\YYYYY/|\:C|/C/
|Y\YYY/Y|Y\YYY/Y|Y\YYY/Y|Y\YYY/Y|C*C|C/
|YY\Y/YY|YY\Y/YY|YY\Y/YY|YY\Y/YY|C:\|/
|YYYXYYY|YYYXYYY|YYYXYYY|YYYXYYY|C'C+
|YY/Y\YY|YY/Y\YY|YY/Y\YY|YY/Y\YY|/C/
|Y/YYY\Y|Y/YYY\Y|Y/YYY\Y|Y/YYY\Y|C/
|/YYYYY\|/YYYYY\|/YYYYY\|/YYYYY\|/
+-------+-------+-------+-------+
Hint

For of the testdata, , and there is no incident light.
For of the testdata, , there is only one incident beam, and its direction is guaranteed to be southeast.
For of the testdata, , the number of blocks stacked at each position does not exceed , the incident light color may be any one of R, G, or B, and there can be at most incident beams.
Translated by ChatGPT 5
京公网安备 11011102002149号