bfs
少年白马
向阳奔跑,逆风成长
展开
-
牛客 maze (BFS/Dijkstra)
题目描述小明来到一个由n x m个格子组成的迷宫,有些格子是陷阱,用’#‘表示,小明进入陷阱就会死亡,’.'表示没有陷阱。小明所在的位置用’S’表示,目的地用’T’表示。小明只能向上下左右相邻的格子移动,每移动一次花费1秒。有q个单向传送阵,每个传送阵各有一个入口和一个出口,入口和出口都在迷宫的格子里,当走到或被传送到一个有传送阵入口的格子时,小明可以选择是否开启传送阵。如果开启传送阵,小明就会被传送到出口对应的格子里,这个过程会花费3秒;如果不开启传送阵,将不会发生任何事情,小明可以继续向上下左右四原创 2020-08-21 22:43:56 · 341 阅读 · 0 评论 -
POJ 3126 Prime Path (BFS)
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 matter of security to change such things every now and th原创 2020-08-14 17:48:16 · 114 阅读 · 0 评论 -
杭电 1242 Rescue (BFS+优先队列)
Problem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel’s friends want to save Angel. Their task is: approach原创 2020-08-05 23:15:43 · 166 阅读 · 0 评论 -
POJ 2251 Dungeon Master (三维BFS)
DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move di原创 2020-08-05 11:12:29 · 117 阅读 · 0 评论 -
杭电 2612 Find a way (双向BFS)
Problem DescriptionPass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki.Yifenfei’s home is at the countryside, but Merceki’s home is in t原创 2020-08-04 18:04:04 · 181 阅读 · 0 评论 -
杭电 1372 Knight Moves(最经典的BFS之模板题)
Problem DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He thinks that the原创 2020-08-04 11:08:41 · 360 阅读 · 0 评论 -
POJ 3984 迷宫(BFS)
Description定义一个二维数组: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表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。Output左上角到右下角的最短路径,格式如样例所示。Sam原创 2020-08-01 21:02:48 · 98 阅读 · 0 评论 -
杭电 1312 Red and Black(BFS/DFS)
Problem DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can’t move on red tiles, he can move onl原创 2020-08-01 16:39:30 · 158 阅读 · 0 评论