#include #define esPar( n ) (( ( n ) % 2 == 0 ) ? true : false) #define multiplo4( n ) (( ( n ) % 4 == 0 ) ? true : false) #define dif_j (abs(j_start - j_end)) #define dif_i (abs(i_start - i_end)) 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. vector moves; //int dif_i = abs(i_start - i_end); //int dif_j = abs(j_start - j_end); if (!esPar(dif_i) || esPar(dif_i) && (!multiplo4(dif_i) && esPar(dif_j) || multiplo4(dif_i) && !esPar(dif_j))) { cout << "Impossible" << endl; } else { while (i_start != i_end && j_start != j_end) { if(i_end < i_start && j_end < j_start){ i_start -= 2; j_start -= 1; moves.insert(moves.end(), 1, "UL"); } if(i_end < i_start && j_end > j_start){ i_start -= 2; j_start += 1; moves.insert(moves.end(), 1, "UR"); } if(i_end > i_start && j_end > j_start){ i_start += 2; j_start += 1; moves.insert(moves.end(), 1, "LR"); } if(i_end > i_start && j_end < j_start){ i_start += 2; j_start -= 1; moves.insert(moves.end(), 1, "LL"); } } if (i_start == i_end){ if(j_start < j_end) moves.insert(moves.end(), dif_j/2, "R"); else moves.insert(moves.end(), dif_j/2, "L"); } if (j_start == j_end){ if (i_start > i_end){ moves.insert(moves.end(), dif_i/4, "UL"); moves.insert(moves.end(), dif_i/4, "UR"); } else{ moves.insert(moves.end(), dif_i/4, "LR"); moves.insert(moves.end(), dif_i/4, "LL"); } } cout << moves.size() << endl; cout << moves.at(0); for(int i=1; i> 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; }