博客
关于我
2018焦作ICPC F. Honeycomb(bfs)
阅读量:748 次
发布时间:2019-03-22

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

思路:比较简单的bfs,我们以每个六边形的中心作为这个六边形的一个整体。很容易看到有六个方向可以走。至于能不能走出去,只需要看六个方向的出口处A是不是空格,是空格的话,假设当前六边形中心为S,要走到的下一个六边形中心为T,容易知道从S走到T的方向和距离就是从S到A的两倍。

坑点

①如果走不到终点要输出-1,没注意看题目,以为保证能走到,wa了一发

②清空标记数组vis用两个for清空,不要用memset对所有点清空 不然会TLE

#include
using namespace std;const int N=(1e3+5)*6;int n,m;int dx[]={ -1,-1,-2,2,1,1};int dy[]={ -3,3,0,0,-3,3};char mp[N][N];bool vis[N][N];int sx,sy;struct node{ int x,y,st;};void bfs(){ for(int i=0;i
que; que.push({ sx,sy,1}); vis[sx][sy]=1; while(!que.empty()){ node now=que.front(); que.pop(); int x=now.x,y=now.y,st=now.st; if(mp[x][y]=='T') { cout<
<
=0 && fx
=0 && fy
>T; while(T--){ cin>>n>>m; n=4*n+3; m=6*m+3; getchar(); for(int i=0;i

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

你可能感兴趣的文章
MySQL 8.0开始Group by不再排序
查看>>
mysql ansi nulls_SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON 什么意思
查看>>
multi swiper bug solution
查看>>
MySQL Binlog 日志监听与 Spring 集成实战
查看>>
MySQL binlog三种模式
查看>>
multi-angle cosine and sines
查看>>
Mysql Can't connect to MySQL server
查看>>
mysql case when 乱码_Mysql CASE WHEN 用法
查看>>
Multicast1
查看>>
mysql client library_MySQL数据库之zabbix3.x安装出现“configure: error: Not found mysqlclient library”的解决办法...
查看>>
MySQL Cluster 7.0.36 发布
查看>>
Multimodal Unsupervised Image-to-Image Translation多通道无监督图像翻译
查看>>
MySQL Cluster与MGR集群实战
查看>>
multipart/form-data与application/octet-stream的区别、application/x-www-form-urlencoded
查看>>
mysql cmake 报错,MySQL云服务器应用及cmake报错解决办法
查看>>
Multiple websites on single instance of IIS
查看>>
mysql CONCAT()函数拼接有NULL
查看>>
multiprocessing.Manager 嵌套共享对象不适用于队列
查看>>
multiprocessing.pool.map 和带有两个参数的函数
查看>>
MYSQL CONCAT函数
查看>>