讨论 / 输出全是0。。。。。。
Nightingalelyy 2016-10-30 19:56:36
点我顶贴 收藏 删除
#include <iostream>

#include <algorithm>

#include <cstdio>

using namespace std;

int a[1001][1001];

int check[1001][1001];

int n,flag,i,j,k,nowx,nowy,head,tail,c,enx,eny,stx,sty;

struct point{

int x;

int y;

int s;

};

point que[1000001];

int next[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

int main()

{

scanf("%d",&n);

getchar();

for(i=1;i<=n;i++)

{

for(j=1;j<=n;j++)

{

c=getchar();

a[i][j]=c-48;

}

getchar();

}

scanf("%d%d",&stx,&sty);

scanf("%d%d",&enx,&eny);

head=1;

tail=1;

flag=0;

que[tail].s=0;

que[tail].x=stx;

que[tail].y=sty;

check[stx][sty]=1;

++tail;

while (head<tail)

{

for(k=0;k<=3;k++)

{

nowx=que[head].x+next[k][0];

nowy=que[head].y+next[k][1];

if(nowx<1 || nowy<1 || nowx>n || nowy>n)

continue;

if(check[nowx][nowy]==0 && a[nowx][nowy]==0)

{

que[tail].s=que[head].s+1;

que[tail].x=nowx;

que[tail].y=nowy;

check[nowx][nowy]=1;

++tail;

}

if (nowx==enx && nowy==eny)

{

flag=-1;

break;

}

}

if (flag==-1) break;

++head;

}

printf("%d",que[tail-1].s);

return 0;

}

#1 Nightingalelyy@2016-10-30 19:56:58
回复 删除
样例过了,但是评测全是0
#2 Alexxuhaoran@2018-04-24 04:26:31
回复 删除
回复 #1 Nightingalelyy:Me Too!!!

#3 Alexxuhaoran@2018-04-24 04:26:47
回复 删除
一定是出bug了

#4 LisaXu@2018-04-26 05:48:13
回复 删除
我也是。。。。

#5 Alexxuhaoran@2018-07-02 20:20:55
回复 删除
我也是

查看更多回复
提交回复