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个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
随机推荐
- 一个不错的安卓下ssh客户端
1.使用安卓作为ssh客户端连接ssh服务器 软件名:JuiceSSH 版本 :1.4.8 大小 :4.22 M 百度网盘地址:JuiceSSH_1.4.8.apk 或 JuiceSSH_1 ...
- Point Grey FlyCapture 实例汇总
Example Language Description AsyncTriggerEx C++ Demonstrates some of the basic asynchronous trigger ...
- MUI - 侧滑菜单
各大APP必备的侧滑菜单栏,支持手势滑动.包含QQ式.美团式等 结构模板 这里是示例Html, 必须使用Mui框架才能使用. 主容器 <div class="mui-off-canva ...
- Centos7 安装codeblock( 转载)
1.安装gcc,需要c和c++两部分,默认安装下,CentOS不安装编译器的,在终端输入以下命令即可 yum install gcc yum install gcc-c++ 2.安装gtk2-deve ...
- ant学习
如果在构建文件当中depends后面有多个依赖,而且这多个依赖还相互依赖,那么只会执行被依赖的任务,不会重复执行任务 ant学习
- 为Eclipse安装主题插件
方法2:通过站点更新 eclipse:Help->Install New Software->Work with:Update Site -http://eclipse-color-the ...
- 图解Java内存回收机制
在Java中,它的内存管理包括两方面:内存分配(创建Java对象的时候)和内存回收,这两方面工作都是由JVM自动完成的,降低了Java程序员的学习难度,避免了像C/C++直接操作内存的危险.但是,也正 ...
- Math-基本功能
<script type="text/javascript"> /* *演示Math对象.该对象中的方法都是静态的.不需要new,直接Math调用即可 */ var n ...
- 【iCore3 双核心板_FPGA】例程一:认识FPGA
实验指导书及代码包下载: http://pan.baidu.com/s/1kUa05FL iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...
- Apache Spark技术实战之4 -- 利用Spark将json文件导入Cassandra
欢迎转载,转载请注明出处. 概要 本文简要介绍如何使用spark-cassandra-connector将json文件导入到cassandra数据库,这是一个使用spark的综合性示例. 前提条件 假 ...