POJ - 1132Border
POJ - 1132Border
Time Limit: 1000MS |
Memory Limit: 10000KB |
64bit IO Format: %I64d & %I64u |
Description
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.)
Input
The first line of the input file 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.
Output
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.
Sample Input
1
2 1
EENNWNENWWWSSSES.
Sample Output
Bitmap #1
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
.XXX............................
X...X...........................
X..X............................
X...X...........................
.X..X...........................
..XX............................
Source
Southwestern European Regional Contest 1996
#include<stdio.h>
#include<string.h> bool b[][]; int main()
{
int cnt = , x = , y = ;
char c = '\0';/*, p = ''*/
scanf("%d", &cnt);
for(int i = ; i < cnt; i++) {
memset(b, , sizeof(b));
printf("Bitmap #%d\n", i+);
scanf("%d%d", &x, &y);
while(true) {
scanf("%c", &c);
if(c == '.') break;
switch(c){
case 'E':
b[x][y-] = ;
x++;
break;
case 'N':
b[x][y] = ;
y++;
break;
case 'W':
b[x-][y] = ;
x--;
break;
case 'S':
b[x-][y-] = ;
y--;
}
} for(int k = ; k >= ; k--) {
for(int j = ; j < ; j++) {
if(b[j][k]) printf("X");
else printf(".");
}
printf("\n");
}
printf("\n");
} return ;
}
POJ - 1132Border的更多相关文章
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
- POJ 2752 Seek the Name, Seek the Fame [kmp]
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17898 Ac ...
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
随机推荐
- 三元表达式、逻辑表达式 与 &&、||的妙用
var a = "123", b = 123; console.log(a === b && "相等" || "不相等"); ...
- java基础--java静态代码块和静态方法的区别、static用法
转载自: http://blog.sina.com.cn/s/blog_afddb8ff0101aqs9.html 静态代码块:有些代码必须在项目启动的时候就执行,这种代码是主动执行的(当类被载入时, ...
- linux修改时区为中国时区(北京)
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- EhCache WebCache 与 SpringMVC集成时 CacheManager冲突的问题
转自:点击打开链接 http://www.cnblogs.com/daxin/p/3560989.html EhCache WebCache 与 SpringMVC集成时 CacheManager冲突 ...
- angular.js学习笔记之一
angular也是一个MVC框架,其中M即model模型表示服务器,V即view视图代表html代码,C即control控制器用来处理用户交互的部分.
- Xcode 添加类前缀
按照如下图所示操作后,接下来创建的类就会带有MN的前缀;如果想更换前缀,则替换MN即可!
- Silverlight控件——如何提升应用程序信任度与问题解决
从silverlight5开始,可以在项目设置中勾选“在浏览器内运行时需要提升的信任”来达到在浏览器内运行提权silverlight客户端的目的,在个特性很有用处. 可我使用这个功能时遇到了一个奇怪的 ...
- php课程---JavaScript与Jquery的区别
使用Jquery必须在页面内引入一个Jquery包 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...
- 【iCore3 双核心板】例程二十:LAN_TCPC实验——以太网数据传输
实验指导书及代码包下载: http://pan.baidu.com/s/1pJY5uXH iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...
- 【iCore3 双核心板_ uC/OS-III】例程六:信号量——共享资源
实验指导书及代码包下载: http://pan.baidu.com/s/1milKoVA iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...