#include #include using namespace std; #define abs(x) x > 0 ? x : -1*x 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. int idiff = i_end - i_start; int jdiff = j_end - j_start; if (idiff % 2 != 0) { cout << "Impossible" << endl; return; } int isteps = idiff/2; int temp = (abs(jdiff) - isteps); if (temp %2 != 0) { cout << "Impossible" << endl; return; } string path = ""; int length = 0; while (idiff != 0) { if (idiff <0 && jdiff <= 0) { path += "UL "; idiff += 2; jdiff +=1; } else if (idiff <0 && jdiff > 0) { path += "UR "; idiff += 2; jdiff -= 1; } else if (idiff > 0 && jdiff >= 0) { path += "LR "; idiff -= 2; jdiff -= 1; } else if (idiff >0 && jdiff < 0) { path += "LL "; idiff -= 2; jdiff += 1; } length++; } while(jdiff != 0) { if (jdiff < 0) { path += "L "; jdiff += 2; } else { path += "R "; jdiff -= 2; } length++; } cout << length << endl; cout << path << endl; } 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; }