请问为什么RE啊!!!!

P1746 离开中山路

C_Cong @ 2019-05-13 23:41:18

#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
char map[1002][1002];
int n,sx,sy,ex,ey,f[1002][1002];
int node[5][2]={{0,0},{0,-1},{-1,0},{0,1},{1,0}};
struct zb
{
    int x,y,bu;
};
queue<zb> Q;
int main()
{
    cin>>n;
    memset(f,10000,sizeof(f));
    for(int a=1;a<=n;a++)
    {
        for(int b=1;b<=n;b++)
        {
            scanf("%c",&map[a][b]);
            if(map[a][b]!='1'&&map[a][b]!='0')
            {
                scanf("%c",&map[a][b]);
            }       
        }
    }
    cin>>sx>>sy>>ex>>ey;
    f[sx][sy]=0;
    Q.push((zb){sx,sy,0});
    while(!Q.empty())
    {
        zb news=Q.front();
        Q.pop();
        for(int a=1;a<=4;a++)
        {
            if(news.y+node[a][1]>0&&news.y+node[a][1]<=n&&news.x+node[a][0]>0&&news.x+node[a][0]<=n&&f[news.x+node[a][0]][news.y+node[a][1]]>news.bu+1&&map[news.x+node[a][0]][news.y+node[a][1]]!='1')
            {
                f[news.x+node[a][0]][news.y+node[a][1]]=news.bu+1;
                Q.push((zb){news.x+node[a][0],news.y+node[a][1],news.bu+1});
            }
        }
    }
    cout<<f[ex][ey]<<endl;
} 

by C_Cong @ 2019-05-13 23:50:27

求助大佬帮忙纠错

#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
int map[1002][1002];
int n,sx,sy,ex,ey,f[1002][1002];
int node[5][2]={{0,0},{0,-1},{-1,0},{0,1},{1,0}};
char s[1002];
struct zb
{
    int x,y,bu;
};
queue<zb> Q;
int main()
{
    cin>>n;
    memset(f,10000,sizeof(f));
    for(int a=1;a<=n;a++)
    {
        scanf("%s",&s);
        for(int b=0;b<=n;b++)
        {
            if (s[b]=='1')
            {
                map[a][b+1]=1;
            }       
        }      
    }
    /*for(int a=1;a<=n;a++)
    {
        for(int b=0;b<n;b++)
        {
            scanf("%c",&map[a][b]);
            if(map[a][b]!='1'&&map[a][b]!='0')
            {
                scanf("%c",&map[a][b]);
            }       
        }
    }*/
    cin>>sx>>sy>>ex>>ey;
    f[sx][sy]=0;
    Q.push((zb){sx,sy,0});
    while(!Q.empty())
    {
        zb news=Q.front();
        Q.pop();
        for(int a=1;a<=4;a++)
        {
            if(news.y+node[a][1]>0&&news.y+node[a][1]<=n&&news.x+node[a][0]>0&&news.x+node[a][0]<=n&&f[news.x+node[a][0]][news.y+node[a][1]]>news.bu+1&&map[news.x+node[a][0]][news.y+node[a][1]]!='1')
            {
                f[news.x+node[a][0]][news.y+node[a][1]]=news.bu+1;
                Q.push((zb){news.x+node[a][0],news.y+node[a][1],news.bu+1});
            }
        }
    }
    cout<<f[ex][ey]<<endl;
} 

by C_Cong @ 2019-05-13 23:52:03

行了,通过了


by ak20070412kevin @ 2019-05-14 00:27:32

@C_Cong


|