洛谷P1747 好奇怪的游戏求两个点之间的最小值,使用bfs深搜,为什么不对,只拿了80分
```c++
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
const int N=29;
int dis[N][N];
bool str[N][N];
int x1,x2,y1,y2;
struct point{
int x;
int y;
};
int dx[12]={-2,-2,-2,-2,-1,1,2,2,2,2,1,-1};
int dy[12]={-2,-1,1,2,2,2,2,1,-1,-2,-2,-2};
int bfs(int x,int y,int ex,int ey){
str[x][y]=true;
dis[x][y]=0;
point cur,next;
queue<point>que;
cur.x=x;
cur.y=y;
que.push(cur);
while(!que.empty()){
cur=que.front();
que.pop();
if(cur.x==ex&&cur.y==ey)
return dis[cur.x][cur.y];
for(int i=0;i<12;i++){
int nx=cur.x+dx[i];
int ny=cur.y+dy[i];
if(nx<=0||ny<=0 ) continue;
if(str[nx][ny]==false){
str[nx][ny]=true;
dis[nx][ny]=dis[cur.x][cur.y]+1;
next.x=nx;
next.y=ny;
que.push(next);
}
}
}
}
int main(){
cin>>x1>>y1>>x2>>y2;
int s1=bfs(x1,y1,1,1);
memset(str,false,sizeof(str));
memset(dis,0,sizeof(dis));
int s2=bfs(x2,y2,1,1);
cout<<s1<<endl<<s2<<endl;
return 0;
}