码迷,mamicode.com
首页 >  
搜索关键字:bfs dfs    ( 14889个结果
DFS-leetcode Combination Sum I/I I
深度优先搜索(DFS)是搜索算法的一种。最早接触DFS应该是在二叉树的遍历里面,二叉树的先序、中序和后序遍历实际上都属于深度优先遍历,实质就是深度优先搜索,后来在图的深度优先遍历中则看到了更纯正的深度优先搜索算法。        通常,我们将回溯法和DFS等同看待,可以用一个等式表示它们的关系:回溯法=DFS+剪枝。所以回溯法是DFS的延伸,其目的在于通过剪枝使得在深度优先搜索过程中如果满足了回...
分类:其他好文   时间:2014-07-08 20:34:20    阅读次数:271
HDU 4403 A very hard Aoshu problem (DFS暴力)
题意:给你一个数字字符串,问在字符串中间加‘=’、‘+’使得‘=’左右两边相等。 1212  : 1+2=1+2,   12=12; 12345666 : 12+3+45+6=66,  1+2+3+4+56=66; #include #include #include #include #include #include #include #include #include #inc...
分类:其他好文   时间:2014-07-08 14:41:26    阅读次数:243
2014 Super Training #9 F A Simple Tree Problem --DFS+线段树
原题: ZOJ 3686http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3686这题本来是一个比较水的线段树,结果一个mark坑了我好几个小时。。哎。太弱。先DFS这棵树,树形结构转换为线性结构,每个节点有一个第一次遍历的时间...
分类:其他好文   时间:2014-07-08 00:46:56    阅读次数:295
2014 Super Training #6 G Trim the Nails --状态压缩+BFS
原题: ZOJ 3675http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3675由m#include #include #include #include #include using namespace std;#defin...
分类:其他好文   时间:2014-07-08 00:31:26    阅读次数:272
UVA 10004 Bicoloring
题目如下: Bicoloring  In 1976 the ``Four Color Map Theorem" was proven with the assistance of acomputer. This theorem states that every map can be colored using only fourcolors, in...
分类:其他好文   时间:2014-07-06 12:28:07    阅读次数:241
UVA 10047 - The Monocycle
题目如下:  Problem A: The Monocycle  A monocycle is a cycle that runs on one wheel and the one we will be considering is a bit more special. It has a solid wheel colored with fiv...
分类:其他好文   时间:2014-07-06 11:49:47    阅读次数:233
Codeforces 29D Ant on the Tree 树的遍历 dfs序
题目链接:点击打开链接 题意: 给定n个节点的树 1为根 则此时叶子节点已经确定 最后一行给出叶子节点的顺序 目标: 遍历树并输出路径,要求遍历叶子节点时按照给定叶子节点的先后顺序访问。 思路: 给每个节点加一个优先级。 把最后一个叶子节点到父节点的路径上的点优先级改为1 把倒数第二个叶子节点到父节点的路径上的点优先级改为2 如此每个点就有一个优先级,每个访问儿子节...
分类:其他好文   时间:2014-07-06 10:11:10    阅读次数:193
USACO concom DFS
写哭了,本来感觉是floyd,但是发现floyd根本不能连续地传递,然后看了题解写了个搜索,这个搜索我都没有想到= = 先贴个floyd的代码,先试图用DFS处理连续控股的情况,再用几个循环处理k1+k2+k3+...Kn 在第八组数据跪了 /* ID:kevin_s1 PROG:concom LANG:C++ */ #include #include #include #inclu...
分类:其他好文   时间:2014-07-06 09:52:55    阅读次数:189
POJ 1101 The Game(BFS+判方向)
The Game Description One morning, you wake up and think: "I am such a good programmer. Why not make some money?'' So you decide to write a computer game. The game takes place on a rectangular...
分类:其他好文   时间:2014-07-06 09:02:34    阅读次数:287
Light OJ 1429 Assassin`s Creed (II) BFS+缩点+最小路径覆盖
题目来源:Light OJ 1429 Assassin`s Creed (II) 题意:最少几个人走完全图 可以重复走 有向图 思路:如果是DAG图并且每个点不能重复走 那么就是裸的最小路径覆盖 现在不是DAG 可能有环 并且每个点可能重复走 对于有环 可以缩点 缩点之后的图是DAG图 另外点可以重复走和POJ 2594一样 先预处理连通性 #include #include #incl...
分类:其他好文   时间:2014-07-06 00:15:53    阅读次数:270
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!