码迷,mamicode.com
首页 >  
搜索关键字:dfs    ( 10564个结果
图的表示与遍历
图的表示:连接矩阵,连接链表。图的遍历:dfs(递归、非递归),bfs.连接矩阵下各种遍历:import java.util.ArrayList;import java.util.LinkedList;import java.util.List;import java.util.Queue;impo...
分类:其他好文   时间:2014-09-11 17:03:02    阅读次数:289
[ACM] hdu 4403 A very hard Aoshu problem (DFS暴搜数字)
A very hard Aoshu problem Problem Description Aoshu is very popular among primary school students. It is mathematics, but much harder than ordinary mathematics for primary school students. T...
分类:其他好文   时间:2014-09-11 15:23:22    阅读次数:150
ZOJ3816-Generalized Palindromic Number(DFS数位搜索)
Generalized Palindromic Number Time Limit: 2 Seconds      Memory Limit: 65536 KB A number that will be the same when it is written forwards or backwards is known as a palindromic number. For exa...
分类:其他好文   时间:2014-09-11 13:55:32    阅读次数:215
Untrusted Patrol 14牡丹江网络赛C
题意:给定一个n个点,m条边的图,其中k个点上有探测器 再给定一个探测器第一次被遍历的序列,问是否存在一种遍历顺序使得满足给定序列且遍历完所有点 思路:从第一个被遍历的探测器开始dfs,每次访问到探测器遍停止,访问到非探测器节点便搜下去。结束后判断给定序列下个探测 器是否被访问过,若没有,说明无法不通过 其他 探测器到达此探测器,无解。若被访问过,继续dfs此结点。 这样d...
分类:其他好文   时间:2014-09-11 12:33:31    阅读次数:168
ZOJ 3817 Chinese Knot(牡丹江网络赛I题)
ZOJ 3817 Chinese Knot 题目链接 思路:万万没想到这题直接hash+暴力剪枝就可以了,把4个串正逆都hash出来,然后每次枚举起点去dfs记录下路径即可,剪枝为如果一旦有一点不匹配就不往后搜(这个很容易想到0 0) 代码: #include #include #include #include using namespace std; type...
分类:其他好文   时间:2014-09-11 11:16:41    阅读次数:196
UVA10410 - Tree Reconstruction(队列)
题目:UVA10410 - Tree Reconstruction(队列) 题目大意:给出一棵树的BFS和DFS遍历,求这棵数,如果有多种情况输出一种就可以了。 解题思路:利用BFS将DFS串分段,分成一棵一棵子树。然后将子树用队列存储下来,因为先被分出来的子树,在下一层中也是最先被分段。注意:一定要将根节点分离出去,它不属于它的子树。这棵树不一定是二叉树。 代码: ...
分类:其他好文   时间:2014-09-11 11:12:51    阅读次数:192
poj1419 Graph Coloring,无向图,最大独立集
最大独立集 = 补图的最大团 最小顶点覆盖 + 最大独立集 = V #include #include const int maxn =100 + 10; int g[maxn][maxn], dp[maxn], n; int x[maxn], ans[maxn], mx; int dfs(int *adj, int ns, int dep) { int t[maxn];...
分类:其他好文   时间:2014-09-11 11:11:11    阅读次数:188
Leetcode dfs&dp Triangle
Triangle  Total Accepted: 17536 Total Submissions: 65508My Submissions Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row...
分类:其他好文   时间:2014-09-11 07:42:01    阅读次数:194
Leetcode dfs Construct Binary Tree from Inorder and Postorder Traversal
Construct Binary Tree from Inorder and Postorder Traversal  Total Accepted: 14363 Total Submissions: 54254My Submissions Given inorder and postorder traversal of a tree, construct the bina...
分类:其他好文   时间:2014-09-11 07:41:51    阅读次数:149
POJ--1699--Best Sequence【扩展KMP+DFS】
链接:http://poj.org/problem?id=1699 题意:给出n个字符串,求他们相连的最小长度,如果首尾字母相同则可以共用相同部分,比如两个串ABCDEF和DEFGHI,他们相连为ABCDEFGHI,最小长度为9,中间的DEF部分共用了。 思路:由于数据量较小,首先对每两个字符串a,b用扩展KMP求出a连在b之后可以共用的长度,用数组B[i][j]表示第j个字符串连接在...
分类:其他好文   时间:2014-09-11 02:19:21    阅读次数:210
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!