
广度优先搜索
RPG_Zero
春日雨,夏蝉鸣,明天是个好天气。
秋风起,雪花轻,海底看不见四季。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 102 二叉树的层次遍历 层次遍历模板题目 队列bfs & 递归dfs
题目链接解法一:BFS模板题,借助于队列AC代码:class Solution {public: vector<vector<int>> levelOrder(TreeNode* root) { // bfs queue<TreeNode*> que; vector<vector<int>> res; if(root!=nullptr) que.push(root)原创 2022-01-19 16:16:15 · 294 阅读 · 0 评论 -
AOJ0558 Cheese 广度优先搜索
题目大意:在H * W的地图上有N个奶酪工厂,分别生产硬度为1~N 的奶酪。有一只吃货老鼠准备从老鼠洞出发吃遍每一个工厂的奶酪。老鼠有一个体力值,初始时为1,每吃一个工厂的奶酪体力值增加1(每个工厂只能吃一次,但不吃该工厂中的奶酪时也可以经过该工厂),且老鼠只能吃硬度不大于当前体力值的奶酪。老鼠从当前格走到相邻的无障碍物的格(上下左右)需要时间1单位,有障碍物的格不能走。走到工厂上时即可吃到该...原创 2019-07-29 15:03:34 · 237 阅读 · 0 评论 -
胜利大逃亡 hdoj 1253 BFS
Ignatius 被魔王抓走了,有一天魔王出差去了,这可是 Ignatius 逃亡的好机会.魔王住在一个城堡里,城堡是一个 ABC 的立方体,可以被表示成 A 个 B*C 的矩阵,刚开始 Ignatius 被关在(0,0,0)的位置,离开城堡的门在(A-1,B-1,C-1)的位置,现在知道魔王将在 T 分钟后回到城堡,Ignatius 每分钟能从一个坐标走到相邻的六个坐标中的其中一个.现...原创 2019-07-03 15:40:21 · 262 阅读 · 0 评论 -
POJ 3669 Meteor Shower BFS
DescriptionBessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find he...原创 2019-07-30 08:29:45 · 231 阅读 · 0 评论 -
Seven Puzzle AOJ 0121 反向BFS
7拼图7数码问题。在2*4的棋盘上,摆有7个棋子,每个棋子上标有1到7的某一个数字,不同棋子上的数字不相同。棋盘还有一个空格,与空格相邻(上下左右)的棋子可以移动到空格中,该棋子原先位置成为空格。给出一个初始状态(保证可以转移到最终状态),找出一种从初始状态转变到给定最终状态的移动棋子最小的步数。Sample Input0 1 2 3 4 5 6 71 0 2 3 4 5 6 77 ...原创 2019-07-30 20:02:44 · 391 阅读 · 0 评论 -
POJ 3126 Prime Path 素数筛法+BFS STL中pair模板使用
DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a ...原创 2019-08-27 15:48:34 · 241 阅读 · 0 评论