文件目录

#include <bits/stdc++.h>
using namespace std;
struct node
{
    int x, y, step;
};
int dir[12][2] = {1, 2, -1, 2, 1, -2, -1, -2, 2, 1, -2, 1, 2, -1, -2, -1, 2, 2, -2, 2, 2, -2, -2, -2};
int bfs(int x, int y)
{
    queue<node> q;
    q.push((node){x, y, 0});
    bool vis[105][105] = {};
    vis[x][y] = true;
    while (!q.empty())
    {
        node u = q.front();
        q.pop();
        if (u.x == 1 && u.y == 1)
            return u.step;
        for (int i = 0; i < 12; i++)
        {
            int xx = u.x + dir[i][0];
            int yy = u.y + dir[i][1];
            if (xx >= 1 && xx <= 100 && yy >= 1 && yy <= 100 && vis[xx][yy] == false)
            {
                vis[xx][yy] = true;
                q.push((node){xx, yy, u.step + 1});
            }
        }
    }
    return -1;
}
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << bfs(a, b) << "\n"
         << bfs(c, d);
    return 0;
}