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 |
在自己机器上好好的 为何提交会RE~ 困惑#include <stdio.h> char dun[35][35][35]; short que[28000][3]; int p,q,l,r,c; int dis[6][3]={{1,0,0},{-1,0,0},{0,1,0},{0,-1,0},{0,0,1},{0,0,-1}}; bool flag; void func(int x,int y, int z) { int i,xx,yy,zz; dun[x][y][z]='#'; for(i=0;i<6;i++) { xx=x+dis[i][0]; yy=y+dis[i][1]; zz=z+dis[i][2]; if(xx>=0&&xx<l&&yy>=0&&yy<r&&zz>=0&&zz<c&&dun[xx][yy][zz]!='#') { if(dun[xx][yy][zz]=='E') { flag=true; break; } q++; que[q][0]=xx; que[q][1]=yy; que[q][2]=zz; } } } int main() { int i,j,k,step,tp,tq; while(scanf("%d%d%d",&l,&r,&c),l||r||c) { getchar(); for(i=0;i<l;i++) { for(j=0;j<r;j++) { for(k=0;k<c;k++) { scanf("%c",&dun[i][j][k]); if(dun[i][j][k]=='S') { que[0][0]=i; que[0][1]=j; que[0][2]=k; } } getchar(); } getchar(); } p=0;q=0; flag=false; step=1; while(1) { tp=p;tq=q; p=q+1; for(i=tp;i<=tq;i++) { func(que[i][0],que[i][1],que[i][2]); if(flag) break; } if(q<p||flag) break; step++; } if(flag==true) printf("Escaped in %d minute(s).\n",step); else printf("Trapped!\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator