#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. if(i_start%2!=i_end%2){ cout<< "Impossible"; }else if(i_start%4==i_end%4?j_start%2!=j_end%2:j_start%2==j_end%2){ cout<< "Impossible"; }else{ bool running = true; vector moves; while((i_start!=i_end||j_start!=j_end)&&running){ if(i_start>i_end){ // Up if(j_start>j_end){ //Up Left j_start-=1; i_start-=2; moves.push_back("UL"); }else if(j_start Up left or up right (considering walls) if(j_start>0){ // Up left j_start-=1; i_start-=2; moves.push_back("UL"); }else if(j_startj_end){ // Down Left j_start-=1; i_start+=2; moves.push_back("LL"); } else if(j_start0){ // Down left j_start-=1; i_start+=2; moves.push_back("LL"); }else{ cout<<"Impossible"; running == false; } } }else{ //Stay level if(j_start> 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; }