#include using namespace std; int M[6][2]={{-1,-2},{1,-2},{2,0},{1,2},{-1,2},{-2,0}}; string MM[]={"UL", "UR", "R", "LR", "LL", "L"}; void calc(vector>& cc, int start[2], int end[2], vector& moves, int cnt, vector& bestmoves) { //cout << start[0] << " " << start[1]<bestmoves.size() && bestmoves.size()>0) return; if(cc[start[0]][start[1]] < cnt) { // cout << "cnt " << cc[start[0]][start[1]] << " " << cnt<(); for(int i=0;i=cc.size() || y>=cc.size()) continue; //cc[x][y] = true; moves[cnt]=i; int p[]={x,y}; calc(cc, p, end, moves, cnt+1, bestmoves); // cc[x][y] = false; } } 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> cc(n, vector(n, INT_MAX)); vector moves(n*n); vector bestmoves; cc[i_start][j_start]=1; int start[] = {i_start, j_start}; int end[] = {i_end, j_end}; calc(cc, start, end, moves, 0, bestmoves); if(bestmoves.size()==0) cout << "Impossible"; else{ cout << bestmoves.size()<> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, j_start, i_start, j_end, i_end); return 0; }