![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
BFS/DFS
Southan97
本科计算机科学与技术专业,现软件工程专业在读研究生
展开
-
HUD 5323 Solve this interesting problem dfs剪枝搜索,重构线段树
HUD 5323 Solve this interesting problem dfs剪枝搜索,重构线段树 Have you learned something about segment tree? If not, don’t worry, I will explain it for you.Segment Tree is a kind of binary tree, it can be defined as this:- For each node u in Segment Tree, u has原创 2017-04-12 19:37:27 · 331 阅读 · 0 评论 -
POJ_2386_Lake Counting
POJ 2386 Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water原创 2016-10-23 16:32:38 · 326 阅读 · 0 评论 -
HDU_5167_Fibonacci
HDU 5167 Following is the recursive definition of Fibonacci sequence:Fi=01Fi−1+Fi−2i = 0i = 1i > 1Now we need to check whether a number can be expressed as the product of numbe原创 2016-10-23 16:26:30 · 304 阅读 · 0 评论 -
HDU_5339_Untitled
HDU 5339 There is an integer a and n integers b1,…,bn. After selecting some numbers from b1,…,bn in any order, say c1,…,cr, we want to make sure that a mod c1 mod c2 mod… mod cr=0 (i.e., a will become the remai原创 2016-10-23 19:58:36 · 351 阅读 · 0 评论 -
HDU_1010_Tempter of the Bone
HDU 1010 The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone原创 2016-10-23 20:18:40 · 390 阅读 · 0 评论 -
HDU_1518_Square
HDU 1518 Given a set of sticks of various lengths, is it possible to join them end-to-end to form a square?原创 2016-10-23 20:23:50 · 266 阅读 · 0 评论 -
POJ_1915_Knight Moves
POJ 1915 Knight Moves Background Mr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?原创 2016-10-23 20:38:09 · 252 阅读 · 0 评论 -
HDU_2717_Catch That Cow
HDU 2717 Catch That Cow Farmer 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原创 2016-10-23 20:43:48 · 244 阅读 · 0 评论 -
HDU_1240_Asteroids!
HDU 1240 Asteroids! You're in space.You want to get home.There are asteroids.You don't want to hit them.原创 2016-10-23 20:48:23 · 334 阅读 · 0 评论 -
DFS&BFS小结
DFS(depth first search):深度优先搜索,即一种有一定策略的枚举 核心:递归 特点: 1. 一搜到底,不通则返 2. 平等遍历,只看方向 3. 只求可行,不求最优 4. 效率过低 DFS伪代码: depthFirstSearch(v) { Label vertex v as reached. for(原创 2016-10-23 21:18:50 · 374 阅读 · 0 评论 -
SPOJ SERGRID Grid BFS搜索算法
SPOJ SERGRID Grid BFS搜索算法 You are on an nxm grid where each square on the grid has a digit on it. From a given square that has digit k on it, a Move consists of jumping exactly k squares in one of the four cardinal directions. A move cannot go beyond the e原创 2017-03-08 22:56:55 · 695 阅读 · 0 评论 -
HDU 1242 Rescue
RescueProblem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M Angel's friends want to save Angel. Their task is: app原创 2017-04-13 23:19:59 · 270 阅读 · 0 评论 -
HUD Crazy Bobo 树上dfs
HUD Crazy Bobo 树上dfs Bobo has a tree,whose vertices are conveniently labeled by 1,2,...,n.Each node has a weight wi. All the weights are distrinct.A set with m nodes v1,v2,...,vm is a Bobo Set if:- The subgraph of his tree induced by this set is connecte原创 2017-04-12 21:24:30 · 315 阅读 · 0 评论 -
POJ_1979_Red and Black
POJ 1979 There 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 c原创 2016-10-23 16:18:05 · 414 阅读 · 0 评论