After playing around with the ASCII Art program you made, wonders…
If you were to only use the draw dot and change colour commands, what is the least number of operations required to recreate a drawing?
To refresh your memory, the draw dot operation draws a single character at the specified coordinate (anywhere you want). The change colour operation changes the colour, or character that operations use. The default colour is .
. The canvas is initially blank (filled with
characters).
Input Specification
The first line will contain two space separated integers, , the number of columns and rows of the drawing.
The next lines will contain characters. Note that the character may be a space.
Output Specification
Output a single integer, the minimum number of operations.
Sample Input 1
5 3
.|...
.| .
.+--.
Sample Output 1
16
Explanation for Sample Output 1
Using the default colour, draw the 8 outer dots.
. ...
. .
. .
Then change the colour and draw the column (1 colour change + 2 draw dots)
.|...
.| .
. .
Then change the colour and draw the cross (1 colour change + 1 draw dot)
.|...
.| .
.+ .
Then change the colour and draw the horizontal line (1 colour change and 2 draw dots)
.|...
.| .
.+--.
That is colour changes + draw dots for a total of operations.
Sample Input 2
11 6
/ / / ,
xxxxxxxx
x O >->-xx-
x >->->-x
XX XxX Xx`
XXX XXX
Sample Output 2
51
Comments
do they have the same restrictions as ASCII art?
not really necessary, sorry if i confused anyone
Yes, added.