| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
明显你的BFS有问题,别人的都有两个while语句.In Reply To:高手看一下,我的BFS哪错了??我的测试数据都对呀!!! Posted by:byron at 2006-07-12 21:07:04 > while(front<=rear)!!!!!!!!!!!!!
> {!!!!!!!!!!!!!!!!!!!!!!!!!!!
> now.x=queue[front].x;
> now.y=queue[front].y;
> now.z=queue[front].z;
> count++;
> for(v=1;v<=6;v++)
> {
> next.x=now.x+move[v].x;
> next.y=now.y+move[v].y;
> next.z=now.z+move[v].z;
> if(!maze[next.x][next.y][next.z])
> {
> rear++;
> queue[rear].x=next.x;
> queue[rear].y=next.y;
> queue[rear].z=next.z;
> maze[next.x][next.y][next.z]=1;
> if(next.x==end.x && next.y==end.y && next.z==end.z)
> {
> count--;
> goto LL;
> }
> }
> }
> front++;
> }
>
> if(front>rear)
> printf("Trapped!\n");
> else
> LL: printf("Escaped in %d minute(s).\n",count);
> scanf("%d%d%d",&L,&R,&C);
> }
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator