#include using namespace std; void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { int up_down = i_start - i_end; //if positive down, if negative up int lf_righ = j_start - j_end; //if positive left, if negarive right int ud = abs(up_down); int lr = abs(lf_righ); int ud2 = ud/2; string str = ""; if((ud % 2 != 0)||(ud2 % 2 != lr % 2)) { //cout< path; //UL = 6; UR = 5; R = 4; LR = 3; LL = 2; L = 1; while(up_down != 0 || lf_righ != 0) { if(up_down > 0) { if((lf_righ >= 0)&&(j_end + lf_righ -1 >= 0)) { path.push_back(6); //str += "UL "; up_down -= 2; lf_righ --; } else { path.push_back(5); str += "UR "; up_down -= 2; lf_righ ++; } } else if(up_down < 0) { if((lf_righ <= 0)&&(j_end + lf_righ + 1 <= n - 1)) { path.push_back(3); str += "LR "; up_down += 2; lf_righ ++; } else { path.push_back(2); str += "LL "; up_down += 2; lf_righ --; } } else { if(lf_righ > 0) { path.push_back(1); str += "L "; lf_righ -= 2; } else { path.push_back(4); str += "R "; lf_righ += 2; } } count++; } sort(path.begin(), path.end()); cout<= 0; i--) { if(path[i] == 6) cout<<"UL "; if(path[i] == 5) cout<<"UR "; if(path[i] == 4) cout<<"R "; if(path[i] == 3) cout<<"LR "; if(path[i] == 2) cout<<"LL "; if(path[i] == 1) cout<<"L "; } } 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; }