used to be a pixel painter. However, times have changed. Technology has advanced. These days, it's all about ASCII. Foreign to the new style, he has become depressed. Cheer him up by writing a program featuring the primitive tools he knows from pixel painting. Each operation will be given to you on a single line.
The features and operations are:
c n
change the colour used to the given ASCII charactern
. The letterc
will strictly be followed by a single space, followed by the character. The colour could be a space.r x y w h
draw a rectangle starting at with a width (columns) and height (rows) of and respectively .f x y w h
draw a filled rectangle starting at with a width (columns) and height (rows) of and respectively .h y a b
draw a horizontal line on row from column to (inclusive) .v x a b
draw a vertical line on column from row to (inclusive) .d x y
draw a dot (pixel) at .s
save the picture (print the art and close your program).
The default (starting) colour is a period .
. The grid initiates with a width and height of 0. It expands so that any edited character/pixel is included in the rectangular area. Note that the point
. When printing, pad and trail spaces so that the output consists of
Input Specification
The farthest pixel ever drawn is at
There will be at most 100 commands. Input will always end with s
on a single line. The finished artwork will never be empty.
Output Specification
A grid of
Note: Output must match exactly.
Sample Input 1
r 1 1 5 3
c -
h 3 2 4
c |
v 2 1 3
c +
d 2 3
s
Sample Output 1
.|...
.| .
.+--.
Explanation for Sample Output 1
First, the 5 by 3 rectangle is drawn with the default colour.
.....
. .
.....
Then the colour is changed to -
. And a horizontal line is drawn.
.....
. .
.---.
The colour is changed once again and a vertical line is drawn.
.|...
.| .
.|--.
The colour is changed to +
and a dot is drawn to yield the final drawing.
.|...
.| .
.+--.
Sample Input 2
c X
f 2 5 8 2
c x
r 1 2 10 3
d 6 5
d 10 5
d 9 3
c >
f 4 3 5 2
c -
d 6 3
d 8 3
d 11 3
d 5 4
d 7 4
d 9 4
c O
d 3 3
c /
d 3 1
d 5 1
d 7 1
c ,
d 9 1
c `
d 11 5
c
d 1 2
d 10 2
d 4 3
d 2 4
d 3 4
d 4 5
d 8 5
d 2 6
d 6 6
s
Sample Output 2
/ / / ,
xxxxxxxx
x O >->-xx-
x >->->-x
XX XxX Xx`
XXX XXX
Comments
If a line has trailing spaces at the end, should we output it or go directly to the next line?
Output.
Is length horizontal and width vertical?
Yes. Changed to
(width) and 
(height) for easier comprehension. Shouldn't affect the input.