
DFS 和 BFS
文章平均质量分 81
yzrefueling
内心的充盈远重于外表的浮华
展开
-
Thrall’s Dream BFS 实现图之间的访问性
We never paid any heed to the ancient prophecies, like fools we clung to the old hatreds, and fought as we had for generations. Until one day the sky rained fire, and a new enemy came upon us. We stan原创 2017-04-29 21:54:59 · 469 阅读 · 0 评论 -
BFS+预处理 POJ - 3669
Bessie 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 her way to a sa原创 2017-04-20 21:48:47 · 430 阅读 · 0 评论 -
【搜索】泡泡龙 DFS
题目描述这是一个简化版的网络游戏:在一个N×N方块构成的棋盘中,每个方块均涂上红、黄、蓝、绿(记为l、2、3、4)中的一种颜色,游戏者可以在最底行任意找一个方块,用鼠标双击这个方块,于是该方块及与之相邻(即在上、下、左、右四个方向上有公共边)的所有的同色方块均被消掉,而因下方失去支持的方块将会自由落下填补空位。样例中给出一个4×4的棋盘样例,当游戏者双击最底层左边第二个方块后,将会形成原创 2017-07-25 18:39:07 · 1219 阅读 · 1 评论 -
HDU - 1180 BFS 诡异的楼梯
Hogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向. 比如下面的例子里,一开始楼梯在竖直方向,一分钟以后它移动到了水平方向,再过一分钟它又回到了竖直方向.Harry发现对他来说很难找到能使得他最快到达目的地的路线,这时Ron(Harry最好的朋友)告诉Harry正好有一个魔法道具可以帮助他寻找这样的路线,而那个魔法道具原创 2017-09-07 10:41:58 · 493 阅读 · 0 评论 -
搜索 BFS HDU - 1072
Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb explodes. The initial原创 2017-08-31 16:02:59 · 358 阅读 · 0 评论 -
深度优先搜索DFS和广度优先搜索BFS的总结
图的遍历顺序有两种:深度优先搜索(DFS)和广度优先搜索(BFS)深度优先算法思想DFS深度优先搜索遍历类似于树的先序遍历。假定给定图G的初态是所有顶点均未被访问过,在G中任选一个顶点i作为遍历的初始点,则深度优先搜索递归调用包含以下操作:(1)访问搜索到的未被访问的邻接点;(2)将此顶点的visited数组元素值置1;(3)搜索该顶点的未被访问的邻接点,若该邻原创 2017-08-31 16:56:15 · 674 阅读 · 0 评论 -
迷宫问题 DFS写法 BFS写法
定义一个二维数组: int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。 In原创 2017-04-04 15:52:14 · 1414 阅读 · 0 评论