为什么我只AC了一个点,其他都RE了......
#include <bits/stdc++.h>
using namespace std;
const int N=1002;
int dt[N][N],n,x2,y2;
int xx[4]={1,0,-1,0};
int yy[4]={0,1,0,-1};
int q[10000000][3];
int tt=0,rr=1;
inline int bbfs(int x,int y,int bs){
for(int i=0;i<4;i++){
if(x+xx[i]>=1&&x+xx[i]<=n&&y+yy[i]>=1&&y+yy[i]<=n&&dt[x+xx[i]][y+yy[i]]==0){
rr++;
if(x+xx[i]==x2&&y+yy[i]==y2)return bs+1;
q[rr][0]=x+xx[i],q[rr][1]=y+yy[i],q[rr][2]=bs+1;
}
}
return 0;
}
inline int bfs(){
while(rr>=tt){
int t=bbfs(q[tt][0],q[tt][1],q[tt][2]);
if(t)return t;
tt++;
}
}
int main(){
std::cin >>n;
for(int i=0;i<n;i++){
string str;
std::cin >>str;
for(int j=0;j<n;j++){
dt[i][j]=str[j]-'0';
}
}
int x,y;
std::cin >>x>>y>>x2>>y2;
q[0][0]=x,q[0][1]=y;
std::cout <<bfs();
return 0;
}