Border

2020年1月17日 1431点热度 0人点赞 0条评论

Border

时间: 1ms        内存:32M

描述:

You are to write a program that draws a border around a closed path into a bitmap, as displayed in the
following figure:
The path is closed and runs along the grid lines, i.e. between the squares of the grid. The path runs
counter-clockwise, so if following the path is considered as going ” forward ” , the border pixels are always
to the ” right ” of the path. The bitmap always covers 32 by 32 squares and has its lower left corner at (0,0).
You can safely assume that the path never touches the bounding rectangle of the bitmap and never
touches or crosses itself. Note that a bit gets set if it is on the outside of the area surrounded by the path
and if at least one of its edges belongs to the path, but not if only one of its corners is in the path. (A look
at the convex corners in the figure should clarify that statement.)

输入:

The first line of the input contains the number of test cases in the file. Each test case that follows
consists of two lines. The first line of each case contains two integer numbers x and y specifying the
starting point of the path. The second line contains a string of variable length. Every letter in the string
symbolizes a move of length one along the grid. Only the letters `W' (``west''), `E' (``east''), `N' (``north''),
`S' (``south''), and `.' (``end of path'', no move) appear in the string. The end-of-path character (`.') is immediately followed by the end of the line.

输出:

For each test case, output a line with the number of the case (`Bitmap #1', `Bitmap #2', etc.). For each
row of the bitmap from top to bottom, print a line where you print a character for every bit in that row
from left to right. Print an uppercase `X' for set bits and a period `.' for unset bits. Output a blank line
after each bitmap.

示例输入:

1
2 1
EENNWNENWWWSSSES.

示例输出:

Bitmap #1
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
.XXX............................
X...X...........................
X..X............................
X...X...........................
.X..X...........................
..XX............................

提示:

参考答案:

解锁文章

没有看到答案?微信扫描二维码可免费解锁文章

微信扫描二维码解锁

使用微信扫描二维码打开广告页面后可以立即关闭,再刷新此页面即可正常浏览此文章

所跳转广告均由第三方提供,并不代表本站观点!

已经扫描此二维码?点此立即跳转

code

这个人很懒,什么都没留下

文章评论