hdu-1253
来源:互联网 发布:base.apk软件下载 编辑:程序博客网 时间:2024/06/06 01:57
http://acm.hdu.edu.cn/showproblem.php?pid=1253
这道水题
#include<stdio.h> #include<iostream> #include<math.h> #include<stdlib.h> #include<ctype.h> #include<algorithm> #include<vector> #include<string.h> #include<queue> #include<stack> #include<set> #include<map> #include<sstream> #include<time.h> #include<utility> #include<malloc.h> #include<stdexcept> using namespace std;int k,n,m,t,tt,T;int mapp[55][55][55]; int vis[55][55][55]; int d[55][55][55]; int xx[6]={0,0,0,0,-1,1}; int yy[6]={0,0,1,-1,0,0}; int zz[6]={1,-1,0,0,0,0}; void bfs() { queue<int> q; vis[1][1][1]=1; d[1][1][1]=0; int s=1*10000+100+1; q.push(s); while(!q.empty()) { s=q.front(); q.pop(); int i; int x,y,z; int tz=s%100; s=s/100; int ty=s%100; s=s/100; int tx=s; for(i=0;i<6;i++) { x=tx+xx[i]; y=ty+yy[i]; z=tz+zz[i]; if(vis[x][y][z]==1||mapp[x][y][z]==1||mapp[x][y][z]==-1) continue; vis[x][y][z]=1; d[x][y][z]=d[tx][ty][tz]+1; q.push(x*10000+y*100+z); } } } int main() { int k; scanf("%d",&k); int cas=1; for(cas=1;cas<=k;cas++) { int a,b,c,t; scanf("%d%d%d%d",&a,&b,&c,&t); int i,j,l; memset(mapp,-1,sizeof(mapp)); memset(vis,0,sizeof(vis)); memset(d,-1,sizeof(d)); for(i=1;i<=a;i++) for(j=1;j<=b;j++) for(l=1;l<=c;l++) scanf("%d",&mapp[i][j][l]); bfs(); if(d[a][b][c] <= t && d[a][b][c] != -1) printf("%d\n",d[a][b][c]); else printf("-1\n"); } return 0; }
0 0
- hdu 1253
- hdu-1253
- HDU 1253
- HDU 1253
- HDU 1253
- HDU 1253
- hdu 1253
- HDU - 1253
- hdu 1253
- hdu 1253
- HDU 1253
- HDU 1253
- hdu 1253 三维bfs
- HDU 1253(BFS)
- HDU[1253]--bfs
- hdu~1253(bfs)
- hdu 1253 bfs
- hdu 1253 bfs
- linux内核epoll实现分析
- 如何在XSLT样式表中声明命名空间
- java中override和java编译器compiler版本的问题
- Spring的SimpleUrlHandlerMapping实例(有三种配法)
- UVA10303 - How Many Trees?(java大数+catalan数)
- hdu-1253
- 平衡二叉树的的插入
- 如何解决“Error detected while processing /root/.vimrc:”
- 神器 VisuAlgo:通过动画学习算法和数据结构
- Unable to execute dex: java.nio.BufferOverflowException.解决办法
- Java学习计划 目标java大神 英语大神 日语大神 游戏大神 动漫大神 说话大神 男神大神
- CF 412 D Giving Awards(拓扑排序)
- unity学习之多态和索引器
- 开发者必备的SQL性能优化基本功