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

本文共 698 字,大约阅读时间需要 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;}

转载地址:http://uwalo.baihongyu.com/

你可能感兴趣的文章
LESS介绍及其与Sass的差异
查看>>
PForDelta索引压缩算法的实现
查看>>
PHP中file_exists()函数不能检测包含中文的文件名的解决办法
查看>>
How can I create a dump of SQL Server?
查看>>
react中实现搜索结果中关键词高亮显示
查看>>
Docker 监控的一点想法
查看>>
从U-Boot显示Logo到Android
查看>>
基于 HTML5 Canvas 的简易 2D 3D 编辑器
查看>>
WINPE下如何直接删除联想隐藏分区?
查看>>
通过NTP协议进行时间同步
查看>>
SQL 问题:已知主键id 和排序条件 这条记录的上一条或下一条记录
查看>>
【转】NSNotificationCenter用法总结
查看>>
jquery 添加节点的几种方法
查看>>
Android WebView 总结
查看>>
创建存储过程和函数
查看>>
[zz]Linux下虚拟化技术深入探讨
查看>>
ASP.NET Cache的一些总结
查看>>
类型名称了解typename的双重意义
查看>>
深入理解计算机系统(1.2)---hello world的程序是如何运行的
查看>>
Json与数组
查看>>