POJ - 1132Border
来源:互联网 发布:零存整取算法 编辑:程序博客网 时间:2024/06/08 03:26
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
1 #include<stdio.h> 2 #include<string.h> 3 4 bool b[32][32]; 5 6 int main() 7 { 8 int cnt = 0, x = 0, y = 0; 9 char c = '\0';/*, p = ''*/10 scanf("%d", &cnt);11 for(int i = 0; i < cnt; i++) {12 memset(b, 0, sizeof(b));13 printf("Bitmap #%d\n", i+1);14 scanf("%d%d", &x, &y);15 while(true) {16 scanf("%c", &c);17 if(c == '.') break;18 switch(c){19 case 'E':20 b[x][y-1] = 1;21 x++;22 break;23 case 'N':24 b[x][y] = 1;25 y++;26 break;27 case 'W':28 b[x-1][y] = 1;29 x--;30 break;31 case 'S':32 b[x-1][y-1] = 1;33 y--;34 }35 }36 37 for(int k = 31; k >= 0; k--) {38 for(int j = 0; j < 32; j++) {39 if(b[j][k]) printf("X");40 else printf(".");41 }42 printf("\n");43 }44 printf("\n");45 }46 47 48 return 0;49 }
- POJ-1132-Border
- POJ - 1132Border
- POJ 1132 Border 笔记
- POJ 1132 Border(边界) 简单模拟
- 文章标题poj 1132: Border(模拟)
- border
- Border
- border
- Border
- Border
- border
- border
- border
- border
- border
- border
- border
- border
- HDU - 1009 FatMouse' Trade
- POJ - 1666 Candy Sharing Game
- POJ - 1978 Hanafuda Shuffle
- POJ - 1245 Programmer, Rank Thyself
- POJ - 1107 W's Cipher
- POJ - 1132Border
- POJ - 2183 Bovine Math Geniuses
- POJ - 2339 Rock, Scissors, Paper
- POJ - 3652 Persistent Bits
- AFNETWORK post请求
- 数位DP 求K进制下0~N的每个数每位上出现的数的总和
- LA 4329 Ping pong 树状数组
- UVA 11624 BFS的妙用
- ios推送信息实现