#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #ifdef __unix__ #include #else #include "bits\stdc++.h" #endif #include #include #include #include #define REP(i,a,b) for(i=a;i route1; int x,y; int index; }; bool map_search(char map[][SIZE], int x,int y,queue& q,route2 now) { if(map[x][y] == '.' || map[x][y] == 0) { route2 next = now; next.x = x , next.y = y; q.push(next); return true; } return false; } route2 wfs(char map[][SIZE],int x,int y,int muki) { queue< route2 > q; route2 now; now.x = x; now.y = y; now.index = 0; q.push(now); while( q.size() ) { now = q.front(); q.pop(); route2 next; int x = now.x , y = now.y; if(map[x][y] == 0) return now; if( map_search(map,x-1, y ,q,now) ) { q.front().route1.push_back(l); } if( map_search(map,x+1, y ,q,now) ) { q.front().route1.push_back(r); } if( map_search(map, x ,y-1,q,now) ) { q.front().route1.push_back(down); } if( map_search(map, x ,y+1,q,now) ) { q.front().route1.push_back(up); } } } int main() { /* cin.tie(0); ios::sync_with_stdio(false); */ char map[SIZE][SIZE] = {0}; int x = SIZE/2 ,y = SIZE/2; int muki = down; int i,j,k; char s[20]; route2 route; print_map(map); while(cin >> s) { if(strcmp(s,"Merry") == 0) break; int a = atoi(s); if(a > 50) cout << "F" << endl; else { draw_map(map,a,x,y,muki); print_map(map); if(route.route1.size() == route.index) { route = wfs(map,x,y,muki); } char c; if(route.route1[route.index] == muki) c = 'F'; else { switch(rand() % 2) { case 0: c = 'R'; break; case 1: c = 'L'; break; } if(c == 'R') { muki++; if(muki > l) muki = up; } else { muki--; if(muki < up) muki = l; } } cout << c << endl; } } cin >> s; return 0; }