@[zlf201101](https://www.luogu.com.cn/user/973280) 我帮你该到了80分
```c++
#include<bits/stdc++.h>
using namespace std;
const int N=1007;
int g[N][N];
bool st[N][N];
int dx[5]={-1,1,0,0};
int dy[5]={0,0,1,-1};
int n,sx,sy,ex,ey,sum;
struct node{
int x,y,step;
}q[N*N];
int tt=-1,hh,tx,ty;
void bfs(int x,int y){
tt++;
q[tt].x=sx;
q[tt].y=sy;
q[tt].step=0;
while(hh<=tt){
for(int i=0;i<4;i++){
if(tx==ex && ty==ey){
cout<<q[tt].step;
exit(0);
}
tx=q[hh].x+dx[i];
ty=q[hh].y+dy[i];
if(tx<1 || tx>n || ty<1 || ty>n)continue;
if(!st[tx][ty]){
tt++;
q[tt].x=tx;
q[tt].y=ty;
q[tt].step=q[hh].step+1;
st[tx][ty]=1;
}
}
hh++;
}
}
int main(){
cin>>n;
char c;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>c;
g[i][j]=c-'0';
}
}
cin>>sx>>sy>>ex>>ey;
bfs(sx,sy);
return 0;
}
```
by _Panyc @ 2024-07-04 09:20:58
改
by _Panyc @ 2024-07-04 09:22:22
@[_Panyc](/user/818558) 最主要的错是什么
by Apollo0130 @ 2024-07-04 09:22:45
1.队列不够规范啊\
2.数组小了
by _Panyc @ 2024-07-04 09:26:04
我最初的代码把对列改大之后也有80分了
**感谢大佬**
![d](https://gss0.baidu.com/-Po3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/6c224f4a20a4462342207d5a9b22720e0cf3d724.jpg)
黑色是队列
白色是我
by Apollo0130 @ 2024-07-04 09:31:08
白色还有 @ _Panyc
by Apollo0130 @ 2024-07-04 09:32:00
@[zlf201101](/user/973280)
你会用STL的队列吗?
by Handezheng @ 2024-07-04 10:27:48
@[Handezheng](/user/1007096) 我用的是数组队列
by Apollo0130 @ 2024-07-04 20:43:41
@[Handezheng](/user/1007096) 我这样改完之后AC了
by Apollo0130 @ 2024-07-04 20:44:09
@[Handezheng](/user/1007096) 谢谢大佬的建议
by Apollo0130 @ 2024-07-04 20:44:43