uva 532
来源:互联网 发布:数据采集卡是板卡吗 编辑:程序博客网 时间:2024/06/01 07:44
题意:三维迷宫逃亡,六个方向。。
#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int MAXN = 10000005;char map[40][40][40];int vis[40][40][40];int dis[MAXN];int l,r,c,x,y,z;int mx[6] = {1, -1, 0, 0, 0, 0}; int my[6] = {0, 0, 1, -1, 0, 0}; int mz[6] = {0, 0, 0, 0, 1, -1};struct node{ int x,y,z;}path[MAXN];int bfs(){ dis[1] = 0 ; path[1].x = x ; path[1].y = y ; path[1].z = z ; memset(vis,false,sizeof(vis)); int front = 1,rear = 2 ; while (front < rear) { for (int i = 0 ; i < 6 ; i++) { int nx = path[front].x + mx[i]; int ny = path[front].y + my[i]; int nz = path[front].z + mz[i]; if (nx>=0 && nx<r && ny>=0 && ny<c && nz>=0 && nz<l) { if (map[nz][nx][ny] == 'E') return dis[front] + 1; if (map[nz][nx][ny] == '.' && !vis[nz][nx][ny]) { vis[nz][nx][ny] = 1 ; dis[rear] = dis[front] + 1; path[rear].x = nx ; path[rear].y = ny ; path[rear].z = nz ; rear++; } } } front++; } return 0;}int main(){ int t; while (scanf("%d%d%d",&l,&r,&c) != EOF && l+r+c) { memset(map,0,sizeof(map)); for (int i = 0 ; i < l ; i++) { for (int j = 0 ; j < r ; j++) { getchar(); for (int k = 0 ; k < c ; k++) { scanf("%c",&map[i][j][k]); if (map[i][j][k] == 'S') { x = j ; y = k ; z = i; } } } getchar(); } t = bfs(); if (t) printf("Escaped in %d minute(s).\n", t); else printf("Trapped!\n"); } return 0;}
- uva 532
- UVA 532
- uva 532
- uva ,532
- uva 532
- UVA 532
- uva 532 - Dungeon Master
- uva 532 - Dungeon Master
- uva 532 - Dungeon Master
- uva 532 - Dungeon Master
- uva-532 - Dungeon Master
- UVa 532 - Dungeon Master
- UVa 532 - Dungeon Master
- UVA 532 - Dungeon Master
- UVA 532 - Dungeon Master
- UVA 532 - Dungeon Master
- UVa 532Dungeon Master
- uva 532 - Dungeon Master
- 将缓冲的数据写入到文件中
- Linux 档案与文件系统的压缩与打包
- HTTP协议 (五) 代理
- UVa 10161: Ant on a Chessboard
- HTTP协议 (六) 状态码详解
- uva 532
- HDU 1520 Anniversary party(简单树形dp)
- 系统杂类-----如何让iphone连接电脑不自动跳出“扫描仪和相机向导”
- HTTP协议 (七) Cookie
- 编译错误-----Kconfig之'endmenu' in different file than 'menu'
- org.directwebremoting.extend.MarshallException: Error marshalling
- python脚本中使用中文注释的方法
- 大学生创业为什么会挂掉?——来自2年实际孵化工作的总结
- 【ScrollView】ScrollView属性