在DEV c++上编译没错,但提交却说编译错误,这是为啥
悬赏一个关注
代码:
#include<bits/stdc++.h>
using namespace std;
int n,fx[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int a[1010][1010],b[1010][1010];
int x1,x2,y1,y2;
struct node{
int x,y,step;
};
void bfs(int x,int y){
queue <node> q;
node t;
t.x=x;
t.y=y;
t.step=0;
a[x][y]=1;
q.push(t);
while(!q.empty()){
t=q.front();
q.pop();
for(int i=0;i<4;i++){
int nx=t.x+fx[i][1];
int ny=t.y+fx[i][0];
if(nx==x2&&ny==y2){
cout<<t.step+1;
return;
}
if(nx>=1&&nx<=n&&ny>=1&&ny<=n&&a[nx][ny]==0){
a[nx][ny]=1;
node tt;
tt.x=nx;
tt.y=ny;
tt.step=t.step+1;
q.push(tt);
}
}
}
return ;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
scanf("%1d",&b[i][j]);
a[i][j]=b[i][j];
}
}
cin>>x1>>y1>>x2>>y2;
bfs(x1,y1);
return 0;
}