Game Draw ---- ---- You and your friends are making your first computer game and its fallen to you to draw the pictures, which consist of simple polygons which are to be filled in with some color. You are restricting things so the polygons have only horizontal and vertical edges, the pixels that must be set have integer coordinates, and the polygon vertices also have integer coordinates. Also to make debugging easier you are, for the moment, representing the picture as a grid of characters on the screen, where `.' denotes a black pixel, and various other characters denote colors. Suppose we start with a 7x14 grid and then draw a poly- gon with vertices which we label 1, 2, 3, 4, 5, 6, 7, 8, after which we fill in the polygon with the color `X'. We get: ..2.3....6.7.. ..XXX....XXX.. .............. ..XXX....XXX.. ....4....5.... ..XXXXXXXXXX.. .............. ..XXXXXXXXXX.. .............. ..XXXXXXXXXX.. ..1........8.. ..XXXXXXXXXX.. .............. .............. Then if we add two polygons, the first with vertices labeled 1, 2, 3, 4 and the second with vertices label- led 5, 6, 7, 8, and both with color `+', we get ..XXX....XXX.. ..XXX....XXX.. ..XXX....XXX.. ..XXX....XXX.. ..XXXXXXXXXX.. ..XXXXXXXXXX.. ..XX12XX67XX.. ..XX++XX++XX.. ..XX43XX58XX.. ..XX++XX++XX.. ..XXXXXXXXXX.. ..XXXXXXXXXX.. .............. .............. where these last two polygon's overlay the first polygon. In general the grid is a rectangle of N x M characters, N lines of M characters each, with (0,0) in the LOWER LEFT and (M-1,N-1) in the UPPER RIGHT. So the vertices of the first polygon are (2,1) (2,6) (4,6) (4,4) (9,4) (9,6) (11,6) (11,1) and of the second two polygons are (4,3) (5,3) (5,2) (4,2) and (8,2) (8,3) (9,3) (9,2) Input ----- For each of several test cases, first a line containing just a test case name, followed by a line containing: N M K where the grid has N lines of M characters and there are K polygons, followed by K polygon description lines each containing: C V x1 y1 x2 y2 ... xV yV where C is the character representing the polygon color, V is the number of polygon vertices, and the vertices are (x1,y1), (x2,y2), ..., (xV,yV) IN CLOCKWISE ORDER. No two edges of the same polygon intersect except at common vertices. All vertices are inside the grid. No edge is 0-length. No two consecutive edges are parallel. No two OVERLAPPING polygons have the same color. No line is longer than 80 characters, so there can be no more than 20 vertices in a polygon. Input ends with an end of file. 2 <= N <= 60 2 <= M <= 80 1 <= K <= 40 Output ------ For each test case, first an exact copy of the test case name line, and then the test case grid consisting of N lines each with exactly M characters, none of which are whitespace. The grid is initialized to all `.''s before any polygons are drawn. Then the polygons are drawn IN ORDER, so each may overlay previously drawn polygons. After all polygons are drawn the grid is output. Sample Input ------ ----- -- BOX --- 4 14 1 X 4 2 1 2 2 11 2 11 1 -- BOX WITH EARS --- 6 14 1 X 8 2 1 2 4 3 4 3 2 10 2 10 4 11 4 11 1 -- BOX WITH EYES --- 6 14 3 X 4 2 1 2 4 11 4 11 1 + 4 4 2 4 3 5 3 5 2 + 4 8 2 8 3 9 3 9 2 -- BOX WITH EARS, EYES, AND NOSE --- 9 14 3 X 8 2 1 2 7 4 7 4 5 9 5 9 7 11 7 11 1 + 4 4 3 4 4 9 4 9 3 * 4 6 0 6 4 7 4 7 0 [IMPORTANTLY there are more samples in sample.in] [BE SURE your program does ALL the samples correctly before you submit.] Sample Output ------ ------ -- BOX --- .............. ..XXXXXXXXXX.. ..XXXXXXXXXX.. .............. -- BOX WITH EARS --- .............. ..XX......XX.. ..XX......XX.. ..XXXXXXXXXX.. ..XXXXXXXXXX.. .............. -- BOX WITH EYES --- .............. ..XXXXXXXXXX.. ..XX++XX++XX.. ..XX++XX++XX.. ..XXXXXXXXXX.. .............. -- BOX WITH EARS, EYES, AND NOSE --- .............. ..XXX....XXX.. ..XXX....XXX.. ..XXXXXXXXXX.. ..XX++**++XX.. ..XX++**++XX.. ..XXXX**XXXX.. ..XXXX**XXXX.. ......**...... [Output for sample.in is in sample.test] File: gamedraw.txt Author: Bob Walton Date: Tue Oct 7 01:41:22 EDT 2014 The authors have placed this file in the public domain; they make no warranty and accept no liability for this file. RCS Info (may not be true date or author): $Author: walton $ $Date: 2014/10/13 11:15:29 $ $RCSfile: gamedraw.txt,v $ $Revision: 1.18 $