ZOJ Problem Set - 2312
The Japan company you are working for produce plotter devices that can draw nice pictures. To support customers who do not posses the special hardware, you were asked to write an emulation driver that simulates the work of the plotter and prints the picture on a computer screen.
The plotter is driven with a simple language consisting of several drawing commands:
POINT x y -- makes a little circle at the given coordinates.
The emulation driver uses few ASCII characters to represent the picture, one character being a basic unit of the coordinate system. The top-left character has coordinates (1,1). The X-axis aims to the right, the Y-axis goes down.
The particular commands are emulated as follows:
POINT: The driver puts a lowercase letter "o" at the given coordinates.
If more objects should be drawn across a single character, the following rules apply:
If the same character is drawn several times, it is used without a change.
Before a script is given to the driver, it is checked by a special preprocessor, which rejects all invalid commands. Therefore, you may assume that all coordinates are within the range of the page. Also, with the LINE command, the two points are always different and the line is strictly either vertical, horizontal, or at the angle of 45o to the axes. There is no assumption on the relative position of the points used with the LINE and CLEAR commands. The text in the TEXT command is always composed only of uppercase letter and digits.
The input consists of several scripts. Each script begins with a line containing two integers X and Y, separated with space, 1 <= X, Y <= 75. These numbers specify the dimensions of the page. Every other line contains exactly one of the above commands. The commands are always uppercase, command arguments are separated with one space.
The PRINT command is always the last command of the script. After the PRINT command, a new script begins. The input is terminated with two zeros, which are not considered to be a script.
For each script, output the emulated picture, created as specified above. After the picture, print one blank line.
+--------------------+ |o |||| | | * / |||| | | \ --*-----++++-| | \ / |||| | | \ / | | | x -- | | | / \ | | | /TES* |||| | | / \ |||| | | / \NICE****U| +--------------------+ +-+ | | +-+ +---+ | | | |-+-| | | | +---+
Source: Czech Technical University Open 2004