#include <bits/stdc++.h> using namespace std; int l,r,c; char a[31][31][31]; int f[31][31][31]; int dir[][3] = {{1,0,0},{-1,0,0},{0,1,0},{0,-1,0},{0,0,1},{0,0,-1}}; int mini = 1e9; void dfs(int x, int y, int z, int cnt){ f[x][y][z] = 1; for(int i = 0; i<6; i++){ int nx = x + dir[i][0]; int ny = y +dir[i][1]; int nz = z + dir[i][2]; if(nx>=0&&nx<l&&ny>=0&&ny<r&&nz>=0&&nz<c&&!f[nx][ny][nz]){ if(a[nx][ny][nz]=='.'){ dfs(nx,ny,nz, cnt+1); } if(a[nx][ny][nz]=='E'){ mini = min(mini, cnt+1); } } } } int main(){ while(cin>>l>>r>>c){ if(l==0&&r==0&&c==0){ break; } mini = 1e9; memset(f, 0, sizeof(f)); for(int i = 0; i<l; i++){ for(int j = 0; j<r; j++){ for(int k = 0; k<c; k++){ cin>>a[i][j][k]; } } } for(int i = 0; i<l; i++){ for(int j = 0; j<r; j++){ for(int k = 0; k<c; k++){ if(a[i][j][k]=='S'){ dfs(i, j, k, 0); } } } } if(mini!=1e9){ printf("Escaped in %d minute(s).\n", mini); } else{ cout<<"Trapped!\n"; } } return 0; } /* Main.cc:2:25: bits/stdc++.h: No such file or directory Main.cc: In function `void dfs(int, int, int, int)': Main.cc:20: error: `min' undeclared (first use this function) Main.cc:20: error: (Each undeclared identifier is reported only once for each function it appears in.) Main.cc: In function `int main()': Main.cc:26: error: `cin' undeclared (first use this function) Main.cc:31: error: `memset' undeclared (first use this function) Main.cc:49: error: `printf' undeclared (first use this function) Main.cc:52: error: `cout' undeclared (first use this function) */ |
Double click to view unformatted code.