您当前的位置: 首页 >  蓝桥杯

不牌不改

暂无认证

  • 2浏览

    0关注

    422博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

蓝桥杯2018年第九届真题-迷宫与陷阱

不牌不改 发布时间:2022-04-05 19:23:33 ,浏览量:2

题目

题目链接

题解

BFS。

主要的特殊点在于加了很多特殊的情况,逐一判断即可。

注意vis/st标记数组是三维的第一维是行号,第二维是列号,第三维是能量值,表示是否以该能量值到达过该点。

代码
#include
using namespace std;
const int N = 1100;

int n, k, st[N*N][15];
string a[N];
int dir[2][4] = {-1, 1, 0, 0, 0, 0, -1, 1};

struct node {
	int first, second, third; // first:位置,second:能量值,third:步数 
};

int bfs () {
	queue  q;
	st[0][0] = 1;
	q.push ({0, 0, 0});
	
	while (q.size()) {
		node t = q.front ();
		int x = t.first / n; // x
		int y = t.first % n; // y
		int m = t.second; // 处于(x,y)位置的能量 
		int d = t.third; // 到达(x,y)的步数 
		q.pop ();
		if (x == n-1 && y == n-1) return d; // 终点 
		for (int i = 0;i > n >> k;
	for (int i = 0;i > a[i];
	
	cout             
关注
打赏
1662186765
查看更多评论
0.0402s