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 |
WR...why?....#include <cstdlib> #include <cstring> #include <memory> #include <cstdio> #include <fstream> #include <iostream> #include <cmath> #include <string> #include <sstream> #include <stack> #include <queue> #include <vector> #include <set> #include <map> #include <algorithm> #include <deque> #include <list> using namespace std; struct node { int c, x, y, step; }; node a[82000]; int l, r, c; const int dir[6][3]={{1,0,0},{-1,0,0}, {0,1,0},{0,-1,0},{0,0,1},{0,0,-1}}; bool u[50][50][50]; char n[50][50][50]; bool ok(int cl,int x,int y) { if(cl>=0&&cl<l&&x>=0&&x<r&&y>=0&&y<c &&!u[cl][x][y]&&n[cl][x][y]=='.') return 1; return 0; } int main() { while(scanf("%d%d%d", &l, &r, &c)+1&& l + r + c) { memset(u,0,sizeof(n)); for(int i = 0; i < l; i++) for(int j = 0; j < r; j++) scanf("%s",n[i][j]); int sc, sx, sy; for(int i = 0; i < l; i++) for(int j = 0; j < r; j++) for(int k = 0; k < c; k++) { if(n[i][j][k]=='S') { sc = i, sx = j, sy = k; } } int front = 0, end = 1; int flag = 0, step = 0; a[0].c = sc, a[0].x = sx, a[0].y = sy, a[0].step = 1; while(front < end) { for(int i = 0; i < 6; i++) { int cl = a[front].c + dir[i][0]; int x = a[front].x + dir[i][1]; int y = a[front].y + dir[i][2]; if(n[cl][x][y]=='E') { flag = 1; step = a[front].step ; goto hi2; } if(ok(cl,x,y)) { a[end].c = cl; a[end].x = x ; a[end].y = y ; a[end++].step = a[front].step + 1; u[cl][x][y] = 1; } } front++; } hi2: if(flag) 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