DFS 基础
胆识与智慧
在探索中成长
展开
-
POJ 1088 滑雪 排序后 dp 或者 记忆化搜索 两种写法
题目描述: Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22原创 2018-01-31 22:25:30 · 253 阅读 · 0 评论 -
Hdu 1258 Sum It Up :DFS 去重
Sum It Up 题目描述: Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t = 4, n = 6, and the list is [4, 3, 2, 2原创 2018-01-30 12:09:12 · 248 阅读 · 0 评论 -
POJ 3009 Curling 2.0 简单递归
题目描述 On Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square原创 2018-01-30 11:22:33 · 192 阅读 · 0 评论 -
POJ 1321 棋盘问题 简单递归
棋盘问题 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。 Input 输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n 当为-1原创 2018-01-30 10:53:15 · 346 阅读 · 0 评论 -
POJ 1101 深搜的剪枝
题目描述: George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks原创 2018-02-04 19:08:40 · 488 阅读 · 0 评论 -
全排列
说到递归,我会想到汉诺塔,n 皇后,还有就是全排列了。当初第一次看这个全排列,看不懂,这么短的代码竟然可以实现全排列的功能,今天就当复习一下。 #include using namespace std ; int n ; int a[105] ; void DFS( int l ){ if( l == n ){ for( int i = 0 ; i < n ; ++i ) cou原创 2018-02-04 12:08:18 · 1006 阅读 · 0 评论 -
POJ 1985 Cow Marathon 求直径 DFS基础 和 BFS 基础
题目描述 Farmer John's pastoral neighborhood has N farms (2 <= N <= 40,000), usually numbered/labeled 1..N. A series of M (1 <= M < 40,000) vertical and horizontal roads each of varying lengths (1 <= l原创 2018-02-03 11:12:55 · 233 阅读 · 0 评论 -
HDU 2488 A Knight's Journey 字典序DFS 记录路径
Background The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the world. Whenever a knight moves, it is two squares in原创 2018-02-01 23:47:39 · 176 阅读 · 0 评论 -
牛客网 E-小G有一个大树 深搜求平衡点
链接:https://www.nowcoder.com/acm/contest/74/E 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format: %lld 题目描述 小G想要把自己家院子里的橘子树搬到家门口(QAQ。。就当小G是大力水手吧)可是小G是个平衡性灰常灰常差的人原创 2018-02-01 19:49:22 · 398 阅读 · 1 评论 -
BZOJ 4602 HYSBZ 4602 齿轮 DFS 或 BFS 或 并查集
题目描述:现有一个传动系统,包含了N个组合齿轮和M个链条。每一个链条连接了两个组合齿轮u和v,并提供了一个传动比x : y。即如果只考虑这两个组合齿轮,编号为u的齿轮转动x圈,编号为v的齿轮会转动y圈。传动比为正表示若编号为u的齿轮顺时针转动,则编号为v的齿轮也顺时针转动。传动比为负表示若编号为u的齿轮顺时针转动,则编号为v的齿轮会逆时针转动。若不同链条的传动比不相容,则有些齿轮无法转动。我们希望...原创 2018-02-21 11:21:27 · 243 阅读 · 0 评论