博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1240——Asteroids!(三维BFS)POJ 2225——Asteroids
阅读量:4568 次
发布时间:2019-06-08

本文共 785 字,大约阅读时间需要 2 分钟。

普通的三维广搜,须要注意的是输入列,行,层

#include
#include
#include
#include
#include
#define M 11using namespace std;int dir[6][3]={
{0,1,0},{0,-1,0},{1,0,0},{-1,0,0},{0,0,1},{0,0,-1}};//6个方向int vis[M][M][M];char map[M][M][M];int n,m,p,sx,sy,sz,ex,ey,ez;bool ck(int x,int y,int z){ if(x>=0&&x
=0&&y
=0&&z
q; node a,b; a.z=sz,a.x=sx,a.y=sy,a.st=0; vis[sz][sx][sy]=1; q.push(a); while(!q.empty()){ a=q.front(),q.pop(); for(int i=0;i<6;++i){ b.x=a.x+dir[i][0]; b.y=a.y+dir[i][1]; b.z=a.z+dir[i][2]; b.st=a.st+1; if(!ck(b.x,b.y,b.z)) continue; if(b.x==ex&&b.y==ey&&b.z==ez){ cout<
<<" "<
<
>str; getchar(); bfs( ); } return 0;}

转载于:https://www.cnblogs.com/blfshiye/p/5065581.html

你可能感兴趣的文章
myeclipse破解方法
查看>>
poj1860 bellman—ford队列优化 Currency Exchange
查看>>
【成长大小事】吃饭+挣钱=在深圳
查看>>
找茬脚本思路(修改中)
查看>>
Java创建线程的细节分析
查看>>
python语法_深浅拷贝
查看>>
使用CCleaner卸载chrome
查看>>
typeof和GetType的区别
查看>>
xtraTabbedMdiManager控件切换时控件不更新的问题
查看>>
为易信正名
查看>>
debian8.4 ibus中文输入法
查看>>
如何使用dos命令查看MySQL当前使用的数据库?
查看>>
猫眼电影爬取(一):requests+正则,并将数据存储到mysql数据库
查看>>
android的ArrayMap类
查看>>
2011年5款备受关注的开源 NoSQL 数据库
查看>>
2-4-1 元组
查看>>
476. Number Complement(补数)
查看>>
[HNOI2015]落忆枫音
查看>>
生成函数
查看>>
HTMl5的存储方式sessionStorage和localStorage详解
查看>>