NYOJ 523 bfs()此题水
来源:互联网 发布:淘宝子账号怎么注册 编辑:程序博客网 时间:2024/06/05 23:06
此题水,,只是为了长记性
#include<stdio.h>#include<string.h>#include<queue>using namespace std;int map[100][100][100];int A,B,C,T;int dx[10] = {0,0,0,0,1,-1};int dy[14] = {0,0,1,-1,0,0};int dz[14] = {1,-1,0,0,0,0};typedef struct N{ int x,y,z; int step;}Ac;queue <Ac> s;void Fz() //控制边界{ for(int i=0;i<=A+5;i++) for(int j=0;j<=B+5;j++) for(int k=0;k<=C+5;k++) map[i][j][k] = 1;}void bfs(){ while(!s.empty()) { Ac Node = s.front(); for(int i=0;i<6;i++) { int x = Node.x + dx[i]; int y = Node.y + dy[i]; int z = Node.z + dz[i]; if(x==A&&y==B&&z==C) { if(Node.step+1<=T&&map[x][y][z]==0) { printf("%d\n",Node.step+1); } else puts("-1"); return ; } if(map[x][y][z]==0) { s.push({x,y,z,Node.step+1}); map[x][y][z] = 1; } } s.pop(); } puts("-1");}int main(){ int n,m; int N; scanf("%d",&N); while(N--) { while(!s.empty())s.pop(); scanf("%d%d%d%d",&A,&B,&C,&T); Fz(); // 长记性,,一个小时 for(int i=1;i<=A;i++) for(int j=1;j<=B;j++) for(int k=1;k<=C;k++) { scanf("%d",&map[i][j][k]); } s.push({1,1,1,0}); bfs(); }}
- NYOJ 523 bfs()此题水
- nyoj 523 亡命逃窜 【BFS】
- nyoj 523 亡命逃窜 【bfs】
- nyoj 82 bfs 好题
- Nyoj 523&&Hud 1253 亡命逃窜[Bfs]
- nyoj 523 亡命逃窜 【三维bfs】
- nyoj--523--亡命逃窜(BFS水题)
- NYOJ 523 亡命逃窜(三维BFS)
- NYOJ 523 亡命逃窜 (bfs)
- nyoj 284 坦克大战 【bfs(简单题)】
- NYOJ skiing(BFS)
- nyoj 325 (bfs +dp)
- 三个水杯 NYOJ BFS
- NYOJ skiing【BFS】
- NYOJ三个水杯【BFS】
- nyoj 三个水杯 (BFS )
- nyoj--58 bfs
- nyoj 483 Nightmare 【bfs】
- Android 网络通讯、通信
- Codeforces Beta Round #95 (Div. 2)
- 代理IP怎么用
- UISegmentedControl的使用
- plsql developer 使用技巧
- NYOJ 523 bfs()此题水
- hdu 1232畅通工程 并查集
- Hadoop 中 IPC 的源码分析
- Xcode 4开发第一个iPhone程序 图文实例
- 分析网站内部优化最重要的因素
- Android 取得文件路径
- 网站关键词布局
- tomcat启动eclipse一个项目时,自动加载已经删除的项目,报错java.lang.IllegalArgumentException
- Qt窗口没有最小化最大化按钮,且最大化显示