#include #include #include #include #include #include #include void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. //7=ul 9=ur 1=ll 3=lr 4=l 6=r int moves[200]; int i = i_start,j = j_start,k,flag = 0,count = 0; while(flag == 0) { if(i_end >= i+2) { i = i+2; if(j_end < j) { j = j-1; moves[count++] = 1; } else if(j_end >= j) { j = j+1; moves[count++] = 3; } } else if(i_end <= i-2) { i = i-2; if(j_end < j) { j = j-1; moves[count++] = 7; } else if(j_end >= j) { j = j+1; moves[count++] = 9; } } else if(i_end == i) { if(j_end >= j+2) { j = j+2; moves[count++] = 6; } else if(j_end <= j-2) { j = j-2; moves[count++] = 4; } else if(j_end == j) { flag = 1; } else { printf("Impossible"); break; } } else { printf("Impossible"); break; } } if(flag == 1) { moves[count] = 5; printf("%d\n",count); for(i=0;moves[i]!=5;i++) { if(moves[i] == 7) printf("UL "); if(moves[i] == 9) printf("UR "); if(moves[i] == 1) printf("LL "); if(moves[i] == 3) printf("LR "); if(moves[i] == 4) printf("L "); if(moves[i] == 6) printf("R "); } } } int main() { int n; scanf("%i", &n); int i_start; int j_start; int i_end; int j_end; scanf("%i %i %i %i", &i_start, &j_start, &i_end, &j_end); printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }