码迷,mamicode.com
首页 >  
搜索关键字:dfs    ( 10564个结果
UVA529- Addition Chains(迭代+DFS)
题目链接 题意:给一个数n,要你找出一个以n为结尾的序列,使得这个序列中的任意一个数(1除外),能由序列中的两个数(可以相同)相加得到。求最短的序列,如有多种组合,任意输出一个。 思路:要迭代+DFS,首先我们可以得到要使序列尽量短的话,那么n最好是能由n/2相加得到,所以我们就可以得到最小深度depth,以depth为基础,进行深搜,如果满足的话就输出,如果不符合的话,再...
分类:其他好文   时间:2014-08-16 13:52:54    阅读次数:253
Cow Marathon
poj1985:http://poj.org/problem?id=1985题意:就是树的直径。题解:直接DFS即可。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int ...
分类:其他好文   时间:2014-08-16 09:40:50    阅读次数:213
LeetCode "Sudoku Solver"
Simply DFS + Backtrace, as N-Queenclass Solution {public: vector> rows; vector> cols; vector>> subboxHm; bool isValid(char c, int i, int j...
分类:其他好文   时间:2014-08-16 07:29:10    阅读次数:166
hdu 1498 50 years, 50 colors
题目链接 1 #include 2 #include 3 4 short G[101][101]; 5 bool vis[101]; 6 short match[101]; 7 short n; 8 9 bool dfs(short x, short c)10 {11 int i;1...
分类:其他好文   时间:2014-08-15 23:47:59    阅读次数:275
HDU2119_Matrix(二分图/最小点覆盖=最大匹配)
解题报告 题意: 题意类似与POJ3041 思路: 见POJ3041解题报告 最小点覆盖。 #include #include #include using namespace std; int mmap[110][110],vis[110],pre[110],n,m; int dfs(int x) { for(int i=1; i<=m; i++) {...
分类:其他好文   时间:2014-08-15 21:12:49    阅读次数:253
1-N全排列
1-N全排列...
分类:其他好文   时间:2014-08-15 19:45:09    阅读次数:166
11181-Probability
不得不说这道题十分猥琐啊,递归求解,我RE了接近20次,最后发现还是数组开小了。 #include #include #include #include #include using namespace std; int biao[250000],n,r,zhi = 0; double p[250000],possi[250000]; int v[250000][25]; void dfs(in...
分类:其他好文   时间:2014-08-15 18:00:59    阅读次数:227
HDU 2614 Beat (dfs)
HDU 2614 Beat (dfs) 题的难度与做题顺序有关...
分类:其他好文   时间:2014-08-15 17:59:29    阅读次数:177
SGU 172.eXam
时间限制:0.25s空间限制:4M题意: 将n(n#include #include using namespace std;int n,m,x,y,tol;bool g[209][209];int f[30009];int dfs(int x){ for(int i=1;i<=n;...
分类:其他好文   时间:2014-08-15 17:34:19    阅读次数:177
二分图基础--Girls and Boys
二分图模板,剩下的就是建图的过程。 int dfs(int a) { int i; for(i=0;i<n;i++) { if(!vis[i]&&mapp[a][i]) { vis[i] = 1; if(dis[i]==-1||dfs(dis[i])) { ...
分类:其他好文   时间:2014-08-15 16:08:19    阅读次数:194
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!