#include #include #include #include #include #include using namespace std; struct cell { int x, y; int dis; string s; cell() {} cell(int x, int y, int dis, string s) : x(x), y(y), dis(dis), s(s){} }; bool isInside(int x, int y, int N) { if (x >= 0 && x < N && y >= 0 && y < N) return true; return false; } void minStepToReachTarget(int knightPos[], int targetPos[],int N) { int dx[] = {-1, 1, 2, 1, -1, -2}; int dy[] = {2, 2, 0, -2, -2, 0}; string path[]={"UL", "UR", "R", "LR", "LL", "L"}; queue q; q.push(cell(knightPos[0], knightPos[1], 0, "")); cell t; int x, y; bool visit[N][N]; for (int i = 0; i < N; i++) for (int j = 0; 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]) { cout<>n; int x1,x2,y1,y2; cin>>x1>>y1>>x2>>y2; int knightPos[] = {y1,n-x1-1}; int targetPos[] = {y2,n-x2-1}; minStepToReachTarget(knightPos, targetPos, n); return 0; }