![](https://img-blog.csdnimg.cn/20190927151124774.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
DFS和BFS
文章平均质量分 71
算法 DFS和BFS
Water_Coder
正在学算法
展开
-
Dungeon Master POJ - 2251(BFS)
Dungeon Master POJ - 2251You 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原创 2021-04-13 17:56:37 · 90 阅读 · 0 评论 -
棋盘问题 POJ - 1321(DFS)
棋盘问题 POJ - 1321在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n当为-1 -1时表示输入结束。随后的n行描述了棋盘的形状:每行有n个字符,其中 #原创 2021-04-13 17:45:17 · 104 阅读 · 0 评论 -
Prime Ring Problem(素数环)递归回溯问题
**Prime Ring Problem(素数环)**题目描述:余队长某天ak太多了心烦,想带领他的队员做游戏 。游戏内容如下:当余队长喊出一个数字n时,便有n个队员,身上带着1到n的数字,手牵手拉成一个环。当环里的每个人相邻两人身上数字之和都为素数时,便找到了一个环。当找出所有的环时,游戏便结束。Note: 每个环的第一个数字必须是1 INPUTn (0 < n <...原创 2019-11-17 10:47:57 · 438 阅读 · 1 评论 -
POJ-3414-Pots(BFS)
PotsYou are given two pots, having the volume of A and B liters respectively. The following operations can be performed:FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap;DROP(i) empty the...原创 2020-02-12 16:34:09 · 263 阅读 · 0 评论 -
POJ-3087- Shuffle'm Up
Shuffle’m UpA common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containin...原创 2020-02-11 16:24:30 · 234 阅读 · 0 评论 -
POJ-3126-Prime Path(BFS)
Prime PathThe 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 ma...原创 2020-02-11 10:36:50 · 270 阅读 · 0 评论 -
POJ-1426-Find The Multiple(DFS)
Find The MultipleGiven a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater ...原创 2020-02-10 17:19:16 · 335 阅读 · 1 评论 -
POJ-3278-Catch That Cow(BFS/队列)
Catch That CowFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K...原创 2020-02-09 17:57:38 · 227 阅读 · 0 评论 -
HDU-1010-Tempter of the Bone(深搜+奇偶剪枝)
Tempter of the Bone翻译:暑假的时候,小明和朋友去迷宫中寻宝。然而,当他拿到宝贝时,迷宫开始剧烈震动,他感到地面正在下沉,他们意识到这是一个陷阱!他们想尽一切办法逃出去。迷宫是一个大小为 N*M 的长方形,迷宫中有一扇门。一开始,门是关着的,他会在第 t 秒的时间打开。因为,小明和朋友必须在第 t 秒到大门口。每一秒,他都可以向上下左右四个方向移动一个点。一旦他移动了,他刚...原创 2020-02-07 16:38:14 · 249 阅读 · 0 评论 -
POJ-3984-迷宫问题
POJ-3984-迷宫问题定义一个二维数组: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 ...原创 2019-12-27 17:58:49 · 571 阅读 · 0 评论 -
HDU-1241-Oil Deposits 油田问题(DFS)
Oil Deposits原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectan...原创 2019-12-27 17:51:12 · 405 阅读 · 0 评论