#include #include #include #include #include #include using namespace std; struct cell { int x, y; int dis; int d; cell() {} cell(int x, int y, int dis) : x(x), y(y), dis(dis),d(d) {} }; string s[]={"h","UL","UR","R","LR","LL","L"}; int dir[200][200]={0}; int dx[]={-2,-2,0,2,2,0}; int dy[]={-1,1,2,1,-1,-2},z=0; void print(int knightPos[],int x,int y) { if(x != knightPos[0] || y != knightPos[1]) { int p=dir[x][y]; x=x-dx[p-1]; y=y-dy[p-1]; print(knightPos,x,y); cout<= 1 && x <= N && y >= 1 && y <= N) return true; return false; } void fun(int knightPos[], int targetPos[],int N) { queue q; q.push(cell(knightPos[0], knightPos[1], 0)); cell t; int x, y; bool visit[N + 1][N + 1]; for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) visit[i][j] = false; visit[knightPos[0]][knightPos[1]] = true; while (!q.empty()) { t = q.front(); q.pop(); visit[t.x][t.y] = true; if (t.x == targetPos[0] && t.y == targetPos[1]) { z=1; cout<>n>>sx>>sy>>ex>>ey; int knightPos[] = {sx+1, sy+1}; int targetPos[] = {ex+1, ey+1}; fun(knightPos,targetPos,n); if(!z) cout<<"Impossible"; return 0; }