求助大佬!!!急!

P1746 离开中山路

hulean @ 2019-01-02 11:32:23

悲惨全WA爆零

看了半天都没看出来什么错误

大佬们帮忙看看

#include<bits/stdc++.h>
using namespace std;
char Map[1100][1100];
int dx[5]={0,0,0,1,-1};
int dy[5]={0,1,-1,0,0};
struct Node
{
    int x,y;
    int cnt;
}p;
int n;
int x_1,x_2,y_1,y_2;
inline void BFS(int zx,int zy)
{
    p.x=zx;p.y=zy;p.cnt=0;
    queue<Node>q;
    q.push(p);
    while(q.size())
    {
        Node next;
        for(int i=1;i<=4;i++)
        {
            next=q.front();
            int a=next.x+dx[i],b=next.y+dy[i];
            if(a<1||b<1||a>n||b>n||Map[a][b]=='1')continue;
            Map[a][b]='1';
            next.x=a;
            next.y=b;
            if(a==x_2&&b==y_2)
            {
                cout<<next.cnt<<endl;
                return;
            }
            next.cnt++;
            q.push(next);
        }
        q.pop();
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)cin>>Map[i][j];
    }
    cin>>x_1>>y_2>>x_2>>y_2;
    Map[x_1][y_1]='1';
    BFS(x_1,y_1);
    return 0;
}

by hulean @ 2019-01-02 11:39:59

已经发现错误了,我太蠢了,连这点小错都查不出TAT


by King_of_gamers @ 2019-01-02 11:54:41

QAQ


by memset0 @ 2019-01-02 12:24:12

@hulean 7 min


by hulean @ 2019-01-02 12:26:07

额......


by King_of_gamers @ 2019-01-02 12:27:43

Orz~~


by HearTheWindSing @ 2019-03-16 19:20:42

呵呵


|