#include using namespace std; #define UNKNOWN 0 #define ISEMPTY 1 #define ISWALL 2 #define UP 0 #define RIGHT 1 #define DOWN 2 #define LEFT 3 int dirtbl[4][2] = { {0,-1},{1,0},{0,1},{-1,0} }; int main() { //初期位置を(19,19)上向きとする int map[39][39]{ {0} }, x = 19, y = 19, dx = 0, dy = -1, n, i, xtmp, ytmp, direction = UP, dirtmp; map[19][19] = ISEMPTY; while (1) { cin >> n; if (cin.fail()) { return 0; } if (n == 20151224) { cout << "F" << endl << flush; x += dx; y += dy; continue; } xtmp = x + dx; ytmp = y + dy; for (i = 0; i < n; i++) { map[xtmp][ytmp] = ISEMPTY; xtmp += dx; ytmp += dy; } map[xtmp][ytmp] = ISWALL; //右? dirtmp = (direction + 1) % 4; xtmp = dirtbl[dirtmp][0]; ytmp = dirtbl[dirtmp][1]; if(map[x + xtmp][y+ytmp]==UNKNOWN){ cout << "R" << endl << flush; direction = dirtmp; dx = xtmp; dy = ytmp; continue; } //左? dirtmp = (direction - 1) % 4; xtmp = dirtbl[dirtmp][0]; ytmp = dirtbl[dirtmp][1]; if (map[x+xtmp][y+ytmp] == UNKNOWN) { cout << "L" << endl << flush; direction = dirtmp; dx = xtmp; dy = ytmp; continue; } //逆? dirtmp = (direction + 2) % 4; xtmp = dirtbl[dirtmp][0]; ytmp = dirtbl[dirtmp][1]; if (map[x+xtmp][y+ytmp] == UNKNOWN) { cout << "R" << endl << flush; direction = dirtmp; dx = xtmp; dy = ytmp; continue; } //壁? if (map[x + dx][y + dy] == ISWALL) { cout << "R" << endl << flush; direction = dirtmp; dx = xtmp; dy = ytmp; continue; } //それ以外 cout << "F" << endl << flush; x += dx; y += dy; } return 0; }