Digital Scoreboard
Time limit2sMemory limit1024 MB
Given segments of a digit on a small grid, scale them by k, then mark every cell within Manhattan distance d-1 of a main cell and print the resulting picture.
- Level
Medium7 of 10
- Topics
- Geometry, Implementation, Brute force, Simulation
- Solved
- No attempts yet
Problem
Arkady Semyonovich Tapkin has an electronic clock in his room. The digits on this clock are shown in a special pseudographic style. Each cell in which a digit is drawn is cells wide and cells high, and the cells in the field are squares.
But recently Arkady Semyonovich has had a problem. Lately his eyesight has gotten worse. For this reason he wants to enlarge the image of these digits. He has already connected an old monitor to the clock, and now the only thing left is to write a program that will draw the digits on the display. Arkady Semyonovich wants to enlarge the image by a factor of and make the line thickness equal to . Help him with this.
Let us describe the notion of <<enlarging by a factor of >> more formally. Number the cells of the field from top to bottom and from left to right. Thus the upper left cell has coordinates , the lower right cell is , the upper right cell is , and the lower left cell is . In addition, introduce a Cartesian rectangular coordinate system such that the origin is at the center of the upper left cell, the axis points to the right, the axis points down, and the length of the unit segment is equal to the side length of a cell. Thus the coordinates of the center of a cell coincide with its coordinates in the numbering introduced above.
Each decimal digit is given by a set of segments that make up its image. For simplicity, each segment is either parallel to one of the coordinate axes or at a 45-degree angle to it.
The digit enlarged by a factor of is drawn on a field of cells horizontally by cells vertically.
When a digit is enlarged by a factor of , the following operations are performed. The coordinates of the points that are the endpoints of the segments making up the digit are multiplied by . After that, the cells through whose centers these segments pass are painted. We call these cells main.
After that, to obtain a line thickness of , the cells whose centers are at a distance not exceeding from the centers of the main cells are painted additionally. The distance between points and is the number .
Given the description of a digit and the parameters and , output the image of the digit enlarged by a factor of with line thickness .
Input
The first line of the input file contains the integers and (, ). The second line of the input file contains the integers and ().
The third line of the input file contains the integer (), the number of segments in the description of the digit. This is followed by lines, each describing one segment. The description of a segment consists of four integers: , , , (, ), the coordinates of the endpoints of the segment.
Each segment is either parallel to one of the coordinate axes or at a 45-degree angle to it. All segments have nonzero length.
Output
The output file must contain exactly lines of characters each. The -th character of the -th line must be the character <<*>> (asterisk) if the cell with center at is painted, and the character <<.>> (dot) otherwise.