附代码:
```cpp
#include<bits/stdc++.h>
#define MAXN 40
#define ll long long
using namespace std;
int n,a,b;
int dx[6]={1,-1,0,0,0,0},dy[6]={0,0,1,-1,0,0},dz[6]={0,0,0,0,1,-1};
bool vis[MAXN][MAXN][MAXN];
char tmap[MAXN][MAXN][MAXN];
struct node{
int x,y,z,step;
};
bool judge(int x,int y,int z){
if(x<0||y<0||z<0||x>=a||y>=b||z>=n) return false;
if(tmap[z][x][y]=='#') return false;
if(vis[z][x][y]) return false;
return true;
}
int bfs(node s,node e){
node now;
queue<node> q;
q.push(s);
while(!q.empty()){
node top=q.front();
q.pop();
if(top.x==e.x&&top.y==e.y&&top.z==e.z) return top.step;
for(int i=0;i<6;i++){
int nx=top.x+dx[i],ny=top.y+dy[i],nz=top.z+dz[i];
if(judge(nx,ny,nz)==true){
now.x=nx,now.y=ny,now.z=nz;
now.step=top.step+1;
q.push(now);
vis[nx][ny][nz]=true;
}
}
}
return -1;
}
int main(){
while(cin>>n>>a>>b){
if(n==0&&a==0&&b==0) return 0;
//memset(vis,0,sizeof(vis));
node s,e;
for(int i=0;i<n;i++){
for(int j=0;j<a;j++){
for(int k=0;k<b;k++){
cin>>tmap[i][j][k];
if(tmap[i][j][k]=='S') s.x=j,s.y=k,s.z=i;
if(tmap[i][j][k]=='E') e.x=j,e.y=k,e.z=i;
}
}
}
int ans=bfs(s,e);
if(ans!=-1) cout<<"Escaped in "<<ans<<" minute(s).\n";
else cout<<"Trapped!\n";
}
return 0;
}
```
by Rice_Demon_King @ 2024-02-01 14:19:45
你绑了吗
by cff_0102 @ 2024-02-01 18:07:16
@[cff_0102](/user/542457) 绑了
by Rice_Demon_King @ 2024-02-02 13:09:53
可能吧。你过几天试试看
by lzdqwq @ 2024-02-02 15:41:50
@[Rice_Demon_King](/user/680022) 好像不能用c++14吧,用C++17
by chenxi797 @ 2024-02-02 17:54:15
@[chenxi797](/user/735165) 交了,还是不行QwQ\
听说前几天UVA比赛时网站被攻击了,是不是因为这个所以不让交?
by Rice_Demon_King @ 2024-02-03 10:55:28
@[Rice_Demon_King](/user/680022) 我没记错 UVA 固定时间段会暴毙自己维护,你访问 <https://onlinejudge.org/> 要是能进去就是能交
by wbs200 @ 2024-02-05 18:49:23
UVA 现在无法注册用户,一直收不到邮件?,大家也有类似的情况吗???
by Yharimium @ 2024-02-06 01:05:22
编译有问题吗
https://www.luogu.com.cn/discuss/776647
by QWQAWAQWQAWA @ 2024-02-15 12:37:36