/*input 7 6 6 0 1 */ #include #include using namespace std; 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. bool isNotReady = true; int numMoves = 0; string final = ""; while(isNotReady) { if(i_start > i_end && j_start > j_end){ i_start -= 2; j_start -= 1; final += "UL "; numMoves++; } else if (i_start == i_end && j_start > j_end) { j_start -= 2; final += "L "; numMoves++; } else if (i_start < i_end && j_start < j_end) { i_start += 2; final += "UR "; numMoves++; } else if (i_start == i_end && j_start < j_end){ i_start = -1; j_start += 2; final += "R "; numMoves++; } else if (i_start < i_end && j_start == j_end){ i_start += 2; final += "LR "; numMoves++; j_start += 1; } else if( i_start < i_end && j_start > j_end){ i_start += 2; final += "LL "; numMoves++; j_start--; } else if (i_start == i_end && j_start == j_end) isNotReady = false; else { final += "Impossible"; isNotReady = false; } } if (final != "Impossible"){ cout << numMoves << endl; cout << final; }else { cout << final; } } int main() { int n; cin >> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }