#include #include #include using namespace std; constexpr int N = 50; // N E S W constexpr array dr = {-1, 0, 1, 0}, dc = { 0, 1, 0, -1}; vector>> seen; void rec(int r, int c, int d, bool save) { if(save) { seen[r][c][d] = true; } string s; cin >> s; if(s[0] == 'M') { exit(0); } int dist = stoi(s); if(dist == 20151224) { cout << 'F' << endl; rec(r+dr[d], c+dc[d], d, true); return; } if(dist) { if(seen[r+dr[d]][c+dc[d]][d]) { int nd = (d + 1) % 4; cout << 'R' << endl; rec(r, c, nd, false); } else { cout << 'F' << endl; rec(r+dr[d], c+dc[d], d, true); } return; } int nd = (d + 1) % 4; cout << 'R' << endl; rec(r, c, nd, false); } int main(void) { seen.assign(N, vector>(N, vector(4, false))); rec(N/2, N/2, 2, true); return 0; }