HELP!!!

P1746 离开中山路

Chouquet @ 2020-01-20 11:17:48

为什么没有输出结果QWQ

#include <stdio.h>
#include <string.h>
#include <queue>
struct node{int x,y,step;}t;
std::queue<node> q;
int x1,y1,x2,y2,n,dis[1005][1005];char map[1005][1005];
const int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
bool vis[1005][1005];
int main(){
    scanf("%d",&n);for(register int i=0;i<n;i++) scanf("%s",map[i]);
    scanf("%d%d",&x1,&y1,&x2,&y2);x1--,x2--,y1--,y2--;
    q.push((node){x1,y1,0});vis[x1][y1]=1;
    while(!q.empty()){
        t=q.front(),q.pop();
        if(t.x==x2&&t.y==y2){printf("%d\n",t.step);break;}
        for(register int i=0;i<4;i++){
            int tx=t.x+dx[i],ty=t.y+dy[i];
            if(tx>=0&&tx<n&&ty>=0&&ty<n&&map[tx][ty]=='0'&&!vis[tx][ty]) q.push((node){tx,ty,t.step+1}),vis[tx][ty]=1;
        }
    }
    return 0;
}

|