#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef complex P; typedef pair pii; #define REP(i,n) for(ll i=0;i>s; if(s=="Merry")break; if(s=="20151224"){ cout << "F" << endl; continue; } G[px][py] = 0; if(visited[px][py]==0){ REP(i,4){ cout << "R" << endl; dir=(dir+1)%4; cin>>s; if(s=="20151224")break; int cnt = atoi(s.c_str()); REP(i,cnt){ G[px+(i+1)*dx[dir]][py+(i+1)*dy[dir]] = 0; } G[px+(cnt+1)*dx[dir]][py+(cnt+1)*dy[dir]] = 1; } if(s=="20151224"){ cout << "F" << endl; continue; } visited[px][py] = 1; } // bfs bool v[100][100];REP(i,100)REP(j,100)v[i][j]=false; v[px][py]=true; queue< pair< pii,vector > > Q; Q.push(make_pair(make_pair(px,py),vector())); int tx=-1,ty=-1; vector tpath; while(!Q.empty()){ pair< pii,vector > P = Q.front(); Q.pop(); int nx = P.first.first, ny = P.first.second; vector path = P.second; path.push_back(make_pair(nx,ny)); REP(i,4){ int nnx = nx+dx[i], nny = ny+dy[i]; if(v[nnx][nny])continue; if(G[nnx][nny]!=0)continue; if(visited[nnx][nny]==0){ tx = nnx; ty = nny; tpath = path; break; } v[nnx][nny] = true; Q.push(make_pair(make_pair(nnx,nny),path)); } if(tx!=-1 && ty!=-1)break; } // trace path and go to (tx,ty) tpath.push_back(make_pair(tx,ty)); REPR(i,tpath.size()){ int vx = tpath[i].first - tpath[i-1].first; int vy = tpath[i].second - tpath[i-1].second; int ndir; if(vx==1)ndir = 0; if(vx==-1)ndir = 2; if(vy==1)ndir = 1; if(vy==-1)ndir = 3; if(dir%2 != ndir%2){ cout << "R" << endl; cin >> s; dir = (dir+1)%4; } if(dir==ndir){ cout << "F" << endl; }else{ cout << "B" << endl; } if(!(tpath[i].first == tx && tpath[i].second == ty)){ cin >> s; } } px = tx; py = ty; } return 0; }