# Poj Solution 1132

```http://poj.org/problem?id=1132

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

#define NMAX 33
#define INF 1000000001
int xp[4]={0,1,0,-1},yp[4]={1,0,-1,0};
int dx[4]={0,0,-1,-1},dy[4]={0,-1,-1,0};
int stx,sty;
int map[NMAX][NMAX];
char in[NMAX*NMAX];

int set(char t)
{
switch(t)
{
case 'N':return 0;
case 'E':return 1;
case 'S':return 2;
case 'W':return 3;
}
return -1;
}
void solve()
{
int i=0;
int cx=stx,cy=sty;
int direct;
while(in[i]!='.')
{
direct=set(in[i]);
map[cy+dy[direct]][cx+dx[direct]]=1;
cx+=xp[direct];
cy+=yp[direct];
i++;
}
int j;
for(i=31;i>=0;i--)
{
for(j=0;j<32;j++)
if(map[i][j]==1)
printf("X");
else
printf(".");
printf("n");
}
printf("n");
}
int main()
{
#if debug
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int t,i;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
printf("Bitmap #%dn",i);
memset(map,0,sizeof(map));
scanf("%d%d",&stx,&sty);

scanf("%s",in);
solve();
}
#if debug
fclose(stdin);
fclose(stdout);
#endif;
return 1;
}
```
This entry was posted in poj. Bookmark the permalink.