@[FIRESTARS](/user/1073342) gengen队 需要我们! QWQ
by 违规用户名K&xs3Z^ @ 2024-08-20 09:01:42
@[违规用户名K&xs3Z^](/user/1271316) 我来了
by FIRESTARS @ 2024-08-20 09:02:29
```cpp
#include<bits/stdc++.h>
using namespace std;
char a[1100][1100];
int m,n;
int sx,sy,ex,ey;
int fx[5]={0,0,1,0,-1};
int fy[5]={0,1,0,-1,0};
int q[1000300][4];
int main()
{
int h=1,t=1;
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>a[i][j];
}
}
cin>>sx>>sy>>ex>>ey;
a[sx][sy]='1';
q[1][1]=sx;
q[1][2]=sy;
q[1][3]=0;
int tx,ty;
while(h<=t){
for(int i=1;i<=4;i++){
tx=q[h][1]+fx[i];
ty=q[h][2]+fy[i];
if(a[tx][ty]=='0'){
a[tx][ty]='1';
t++;
q[t][1]=tx;
q[t][2]=ty;
q[t][3]=q[h][3]+1;
if(tx==ex&&ty==ey){
cout<<q[t][3]<<endl;
return 0;
}
}
}
h++;
}
}
```
by Whitecrane @ 2024-08-20 09:02:46
用什么队列啊,数组就行
by Whitecrane @ 2024-08-20 09:03:53
@[违规用户名K&xs3Z^](/user/1271316) 你的步数记录有问题
by FIRESTARS @ 2024-08-20 09:04:09
@[违规用户名K&xs3Z^](/user/1271316) 并不是说这是第几个被加入队列的格子这就是从起始点到他的步数
by FIRESTARS @ 2024-08-20 09:04:49
@[FIRESTARS](/user/1073342) ok 窝看看
by 违规用户名K&xs3Z^ @ 2024-08-20 09:05:05
@[违规用户名K&xs3Z^](/user/1271316)
hack:
```
3
000
000
000
1 1 3 3
```
by FIRESTARS @ 2024-08-20 09:05:30
楼上正解
by tireden @ 2024-08-20 09:05:37
https://www.luogu.com.cn/paste/b88ji1co
by Deeplove_lzs @ 2024-08-20 09:05:57