# BAPC2014 J&&HUNNU11590:Jury Jeopardy

F：往前走一步

R：右转并往前走一步

L：左转并往前走一步

B：后转并往前走一步

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

#define ls 2*i
#define rs 2*i+1
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define LL long long
#define ULL unsigned long long
#define N 100005
#define INF 0x3f3f3f3f
#define EXP 1e-8
#define rank rank1
const int mod = 1000000007;

int t,len;
char str[1000000];
int to[4][2]={0,1,1,0,0,-1,-1,0},vis[300][300];

int main()
{
int i,j,k;
scanf("%d",&t);
printf("%d\n",t);
while(t--)
{
MEM(vis,0);
scanf("%s",str);
len = strlen(str);
int r = 0;
int x = 128,y=128;
vis[x][y] = 1;
int maxx,maxy,minx,miny;
maxx = maxy = minx = miny = 128;
for(i = 0;i<len;i++)
{
if(str[i]=='F')
{
x+=to[r][0];
y+=to[r][1];
vis[x][y] = 1;
}
else if(str[i]=='R')
{
r = (r+1)%4;
x+=to[r][0];
y+=to[r][1];
vis[x][y] = 1;
}
else if(str[i]=='B')
{
r = (r+2)%4;
x+=to[r][0];
y+=to[r][1];
vis[x][y] = 1;
}
else if(str[i]=='L')
{
r = (r+3)%4;
x+=to[r][0];
y+=to[r][1];
vis[x][y] = 1;
}
maxx = max(maxx,x);
maxy = max(maxy,y);
minx = min(minx,x);
miny = min(miny,y);
}
printf("%d %d\n",maxx-minx+3,maxy-miny+2);
for(i = minx-1;i<=maxx+1;i++)
{
for(j = miny;j<=maxy+1;j++)
{
if(vis[i][j]) printf(".");
else printf("#");
}
printf("\n");
}

}

return 0;
}

04-02
12-24

03-25
04-26 120
07-26 112
02-13 1465
07-11 71