ZOJ Problem Set - 2572
When we post our ideas on bbs, sometimes we want to post it in colors so that it is easier to read and more beautiful. Now you are asked to write a program to generate some colored bbs characters.
To simplify the problem, we can assume that the line of the characters is formed by one of the following characters: dash ("-"), pipe ("|"), slash ("/"), or backslash ("\"), according to its direction. If pipe and minus characters are involved, they result in the plus sign ("+"). If slashes and backslashes are involved, the result is the uppercase letter "X". Otherwise, the asterisk ("*") is displayed. The colored characters can be shown in the following form: [m (color number) (string) m] (NOTICE the qutations are added only to show the form) . Here the string does not contain white spaces or enters. When you are asked to color some line, you must also color the lines that cross the line.
Your task is to color the given lines with specified colors. The codes shorter are preferrable.
The input contain two parts. The first line of the first part contain two integers n, m, indicating the length and the width of the character array, n,m <= 100. Then n lines of characters follow. The first line of the second part contains a nonnegative integer k. Then k lines follow, in the form of xi yi ci, xi, yi >= 0, ci >0, meaning you must color the character in (xi, yi) with color ci. The rows and columns are from 0 from up to down and from left to right. You can assume that no character will be colored twice.
Process to the end of file.
Output the codes that show the colored character on the bbs.
7 19 | \ -+- -------- +-+ |/ \ / | | * \ / +-+ /| \ / \| \/ * -------- 2 2 0 31 0 6 33
[m33|m] \ [m33-+-m] -------- [m31+-+m] [m33|/m] \ / [m31|m] [m31|m] [m33*m] \ / [m31+-+m] [m33/|m] \ / [m33\|m] \/ [m33*m] --------
Author: GUAN, Yao
Source: ZOJ Monthly, October 2005