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 |
为什么WA啊,求大牛指教!!!!!#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <queue> using namespace std; queue<int> q1; queue<int> q2; queue<int> q3; int a[]={1,-1,0,0,0,0}; int b[]={0,0,1,-1,0,0}; int c[]={0,0,0,0,1,-1}; int main() { int l,m,n; char map[35][35][35]; int s1,s2,s3,ans,len,T; //freopen("in.txt","r",stdin); while(scanf("%d%d%d",&l,&m,&n)!=EOF&&l!=0&&m!=0&&n!=0) { ans=0;T=0; memset(map,'#',sizeof(map)); while(q1.size()!=0) { q1.pop(); q2.pop(); q3.pop(); } getchar(); for(int i=1;i<=l;i++) { for(int j=1;j<=m;j++) { for(int k=1;k<=n;k++) { scanf("%c",&map[j][k][i]); } getchar(); } getchar(); } for(int i=1;i<=l;i++) for(int j=1;j<=m;j++) for(int k=1;k<=n;k++) { if(map[j][k][i]=='S') { s1=i;s2=j;s3=k; break; } } q1.push(s1);q2.push(s2);q3.push(s3); while(q1.size()!=0) { len=q1.size(); ans++; for(int j=1;j<=len;j++) { s1=q1.front();s2=q2.front();s3=q3.front(); q1.pop();q2.pop();q3.pop(); if(map[s2][s3][s1]=='E') { printf("Escaped in %d minute(s).\n",ans-1); T=1; break; } for(int s11,s22,s33,i=0;i<6;i++) { s11=s1+a[i]; s22=s2+b[i]; s33=s3+c[i]; if(s11>=1&&s11<=l&&s22>=1&&s22<=m&&s33>=1&&s33<=n) { if(map[s22][s33][s11]=='E') { q1.push(s11);q2.push(s22);q3.push(s33); } else if(map[s22][s33][s11]=='.') { q1.push(s11);q2.push(s22);q3.push(s33); map[s22][s33][s11]='#'; } } } } } if(T==0) 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