#include #include #include #include #include #include #include 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 x,y,z=1,a,b,i,j,back,moves=0; y=i_start-i_end; x=j_start-j_end; if(x<0){ x=x*(-1); } if(y<0){ y=y*(-1); } if(y%2==0){ if(y%4==0 && x%2==1){ z=0; } if(y%4!=0 && x%2==0){ z=0; } }else{ z=0; } if(z==0){ printf("Impossible\n"); }else if(i_startj_end){ b=i_start-i_end; b=b/2; a=j_end-j_start-b; back=0; if(a<0){ a=a*(-1); a=a/2; b=b-a; back=a; a=0; }else{ a=a/2; } moves=a+b+back; printf("%d\n",moves); for(i=0;ii_end && j_starti_end && j_start>j_end){ b=i_start-i_end; b=b/2; a=j_start-j_end-b; back=0; if(a<0){ a=a*(-1); a=a/2; b=b-a; back=a; a=0; }else{ a=a/2; } moves=a+b+back; printf("%d\n",moves); for(i=0;i