#include #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. int i1 = i_start; int i2 = i_end; int j1 = j_start; int j2 = j_end; int count =0; // vector move; vector c(n*n); while(1) { if(i1 >= 0 && j1 >= 0) { if(i1 < i2) { if((j1-j2) <= 0) { j1 = j1 + 1; i1 = i1 + 2; //i1 = i; //j1 = j; c.push_back("LR "); //c.push_back(move); count++; } else { j1 = j1 - 1; i1 = i1 + 2; //i1 = i; //j1 = j; c.push_back("LL "); //c.push_back(move); count++; } } if (i1 > i2) { if((j1 - j2) >= 0) { j1 = j1 - 1; i1 = i1 - 2; // i1 = i; // j1 = j; c.push_back("UL "); //c.push_back(move); count++; } else { j1 = j1 - 1; i1 = i1 - 2; // i1 = i; // j1 = j; c.push_back("UR "); // c.push_back(move); count++; } } if(i1 == i2 && j1 != j2) { if( (j1 - j2) < 0) { j1 = j1 + 2; c.push_back ("R "); //c.push_back(move); count++; } else { j1 = j1 - 2; c.push_back("L "); //c.push_back(move); count++; } } } else { cout<<"Impossible"; break; } if(i1==i2 && j1==j2) { break; } } if(i1==i2) { 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; }