传送门
#include<bits/stdc++.h>
using namespace std;
int a[12]={1,1,2,2,2,2,-1,-1,-2,-2,-2,-2};
int b[12]={-2,2,-2,-1,1,2,-2,2,-1,1,-2,2};
struct node{
int x,y,step;
};
queue<node>q;
int vis[50][50];
int bfs(int x1,int y1,int ans)
{
while(!q.empty())
q.pop();
memset(vis,0,sizeof(vis));
node now,next;
now.x = x1;
now.y = y1;
now.step = 0;
q.push(now);
while(!q.empty())
{
now=q.front();
q.pop();
if(now.x == 1 &&now.y == 1)
{
ans = now.step;
break;
}
for(int i = 0; i < 12; i++)
{
next.x = now.x+a[i];
next.step = now.step+1;
next.y = now.y+b[i];
if(next.x >= 1&&next.y>=1&&next.x<=40&&next.y<=40&&!vis[next.x][next.y])
{
// printf("%d %d %d\n",next.x,next.y,next.step);
q.push(next);
vis[next.x][next.y] = 1;
}
}
}
}
int main()
{
int ans2 = 0x3f3f3f3f;
int ans = 0x3f3f3f3f;
int x1,y1;
int x2,y2;
cin>>x1>>y1;
cin>>x2>>y2;
ans = bfs(x1,y1,ans);
ans2 = bfs(x2,y2,ans2);
printf("%d\n%d\n",ans,ans2);
}