求修改代码,开o2就RE
#include<bits/stdc++.h>
#include<vector>
using namespace std;
long long x1,x2,y11,y2,book[2000][2000],tail=1,hand=1,ty,tx,flag,book1[2000][2000];
struct sb
{
int x;
int y;
int s;
}a[1000000],b[1000000];
int main()
{
int qwe[12][2]={{-2,2},{-2,1},{-1,2},{2,2},{2,1},{1,2},{-2,-2},{-2,-1},{-1,-2},{2,-1},{1,-2}/*,{2,-2}*/};
cin>>x1>>y11>>x2>>y2;
book[x1][y11]=1;
a[hand].x=x1;
a[hand].y=y11;
tail++;
while(hand<tail)
{
for(int i=0;i<13;i++)
{
tx=a[hand].x+qwe[i][0];
ty=a[hand].y+qwe[i][1];
if(tx<1 or ty<1) continue;
if(book[tx][ty]==0)
{
book[tx][ty]=1;
a[tail].x=tx;
a[tail].s=a[hand].s+1;
a[tail].y=ty;
tail++;
}
if(a[tail-1].x==1 and a[tail-1].y==1)
{
flag=1;
break;
}
}
if(flag==1) break;
hand++;
}
cout<<a[tail-1].s<<endl;
flag=0;
hand=1;
tail=1;
book[x2][y2]=1;
b[hand].x=x2;
b[hand].y=y2;
tail++;
while(hand<tail)
{
for(int i=0;i<13;i++)
{
tx=b[hand].x+qwe[i][0];
ty=b[hand].y+qwe[i][1];
if(tx<1 or ty<1) continue;
if(book1[tx][ty]==0)
{
book1[tx][ty]=1;
b[tail].x=tx;
b[tail].s=b[hand].s+1;
b[tail].y=ty;
tail++;
}
if(b[tail-1].x==1 and b[tail-1].y==1)
{
flag=1;
break;
}
}
if(flag==1) break;
hand++;
}
cout<<b[tail-1].s;
return 0;
}