#include using namespace std; void printShortestPath(int n, int is, int js, int ie, int je) { // Print the distance along with the sequence of moves. string imp = "Impossible"; int wid = abs(js-je); int ht = abs(is-ie); if(ht%2!=0){ cout<js){ r = wid/2; } else { l = wid/2; } } if(ie < is){ if(je>=js){ if(wid >= ht/2){ ur = ht/2; r = (wid - ht/2)/2; } else { ur = (wid + ht/2)/2; ul = (ht/2 - wid)/2; } } else { if(wid >= ht/2){ ul = ht/2; l = (wid - ht/2)/2; } else { ul = (wid + ht/2)/2; ur = (ht/2 - wid)/2; } } } else { if(je>=js){ if(wid >= ht/2){ lr = ht/2; r = (wid - ht/2)/2; } else { lr = (wid + ht/2)/2; ll = (ht/2 - wid)/2; } } else { if(wid >= ht/2){ ll = ht/2; l = (wid - ht/2)/2; } else { ll = (wid + ht/2)/2; lr = (ht/2 - wid)/2; } } } cout<=0 && js - 1>=0 && ul ){ ul--; is -= 2; js--; cout<<"UL "; continue; } if(is - 2>=0 && js + 1 < n && ur ){ ur--; is -= 2; js++; cout<<"UR "; continue; } if(js + 2 < n && r){ r--; js += 2; cout<<"R "; continue; } if(is + 2=0 && ll ){ ll--; is += 2; js--; cout<<"LL "; continue; } if(js - 2 >= 0 && l ){ l--; js-=2; cout<<"L "; continue; } } cout<> 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; }