
DFS
文章平均质量分 68
Aerolite坠落
这个作者很懒,什么都没留下…
展开
-
图结构练习——DFS——判断可达性
题目描述 在古老的魔兽传说中,有两个军团,一个叫天灾,一个叫近卫。在他们所在的地域,有n个隘口,编号为1..n,某些隘口之间是有通道连接的。其中近卫军团在1号隘口,天灾军团在n号隘口。某一天,天灾军团的领袖巫妖王决定派兵攻打近卫军团,天灾军团的部队如此庞大,甚至可以填江过河。但是巫妖王不想付出不必要的代价,他想知道在不修建任何通道的前提下,部队是否可以通过隘口及其相关通道到达近卫军团展开攻原创 2014-02-21 18:41:10 · 1130 阅读 · 0 评论 -
(福大2015年3月月赛)FZU 2185 树的路径覆盖 (DFS)
题目地址:FZU 2185 允许重复覆盖的值比较好求,一条路径覆盖两个叶子节点,所以答案是(叶子结点数+1)/2。至于不允许重复覆盖的,我第一次想的是叶子节点数-1,因为先让第一条覆盖两个叶子结点,后面的每条覆盖一个,但是显然作为渣渣的我太native了。 很显然,当所有叶子节点都指向一个节点的时候肯定不是,这时候可以一条路径覆盖两个叶子节点。原创 2015-03-24 21:11:17 · 985 阅读 · 0 评论 -
HDU 1016Prime Ring Problem(dfs)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1016原创 2014-05-14 16:45:23 · 936 阅读 · 0 评论 -
HDU 1010 Tempter of the Bone(DFS+剪枝)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1010 这题T原创 2014-05-07 14:30:44 · 980 阅读 · 2 评论 -
UVa 705 Slash Maze(DFS)(斜线构图)
By filling a rectangle with slashes (/) and backslashes ( ), you can generate nice little mazes. Here is an example: As you can see, paths in the maze cannot branch, so the whole maze only co原创 2014-05-01 19:04:49 · 951 阅读 · 0 评论 -
UVa 657 The die is cast(DFS*2)
Description The die is cast InterGames is a high-tech startup company that specializes in developing technology that allows users to play games over the Internet. A mark原创 2014-04-14 20:03:18 · 983 阅读 · 0 评论 -
UVA10004Bicoloring(DFS)二分染色
Bicoloring In 1976 the ``Four Color Map Theorem" was proven with the assistance of a computer. This theorem states that every map can be colored using only four colors, in such a way that原创 2014-03-08 23:37:27 · 1043 阅读 · 0 评论 -
HDU 1241Oil Deposits(dfs搜索)
Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates原创 2014-02-17 14:41:27 · 805 阅读 · 0 评论 -
图的深度遍历
题目描述 请定一个无向图,顶点编号从0到n-1,用深度优先搜索(DFS),遍历并输出。遍历时,先遍历节点编号小的。 输入 输入第一行为整数n(0 输出 输出有n行,对应n组输出,每行为用空格隔开的k个整数,对应一组数据,表示DFS的遍历结果。 示例输入 1 4 4 0 1 0 2 0 3 2 3 示例输出 0 1 2 3 提示原创 2014-02-21 18:39:41 · 834 阅读 · 0 评论 -
Codeforces Round #316 (Div. 2) D. Tree Requests (DFS序)
题目地址:http://codeforces.com/contest/570/problem/D 比赛的时候实在没想到DFS序,。。想到DFS序后,分别存起每个深度的所有节点的DFS序,处理出前缀异或和,然后二分找到两个端点,再异或一下,就求出了所求区间的异或和,由于偶数次的都被异或掉了,所以判断下奇数次数是否大于1即可。 代码如下:#include <iostream> #include <s原创 2015-08-17 10:21:15 · 1224 阅读 · 2 评论