码迷,mamicode.com
首页 >  
搜索关键字:DFS Troubleshooting    ( 10753个结果
POJ - 2688 Cleaning Robot
题意:求回收所有垃圾的最短路 思路:先BFS处理两个垃圾的距离,然后DFS记忆化搜索           dp[i][state]表示处理到第i个后状态是state的最短路 #include #include #include #include #include #include using namespace std; const int MAXN = 30; const in...
分类:其他好文   时间:2014-06-19 12:55:30    阅读次数:412
经典图算法Java代码实践:BFS,DFS以及几种最短路径算法
public class City { String name; int id; static int idCounter = 0; public City(String name) { this.name=name; id = idCounter++; } } import java.util.ArrayList; public class Gr...
分类:编程语言   时间:2014-06-19 10:36:26    阅读次数:196
LeetCode:Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: Given the below binary tree and sum = 22, 5 ...
分类:其他好文   时间:2014-06-15 19:55:39    阅读次数:191
NYOJ325 zb的生日 【DFS】
zb的生日 时间限制:3000 ms  |  内存限制:65535 KB 难度:2 描述今天是阴历七月初五,acm队员zb的生日。zb正在和C小加、never在武汉集训。他想给这两位兄弟买点什么庆祝生日,经过调查,zb发现C小加和never都很喜欢吃西瓜,而且一吃就是一堆的那种,zb立刻下定决心买了一堆西瓜。当他准备把西瓜送给C小加和never的时候,遇到了一个难题,ne...
分类:其他好文   时间:2014-06-15 19:12:07    阅读次数:182
二分匹配模版
const int maxn = 10010; int vis[maxn]; int y[maxn]; vector G[maxn]; int n; bool dfs(int u) { for(int i = 0; i < G[u].size(); i++) { int v = G[u][i]; if(vis[v]) continue; vis[v] = true; ...
分类:其他好文   时间:2014-06-15 18:34:38    阅读次数:186
hdu 2489 Minimal Ratio Tree(dfs枚举 + 最小生成树)~~~
题目:         链接:点击打开链接 题意:         输入n个点,要求选m个点满足连接m个点的m-1条边权值和sum与点的权值和ans最小,即sum/ans最小,并输出所选的m个点,如果有多种情况就选第一个点最小的,如果第一个点也相同就选第二个点最小的........ 求一个图中的一颗子树,使得Sum(edge weight)/Sum(point weight)最小~ 数据...
分类:其他好文   时间:2014-06-14 07:05:34    阅读次数:350
dfs模版
dfs#include #include char Map[16][16];int mv[16][16];//mv[i][j] == 0 没有被访问//mv[i][j] == 1 已经被访问struct N{int x,y;} ;int jx[] = { 0,-1, 0, 1};int jy[] =...
分类:其他好文   时间:2014-06-13 17:45:35    阅读次数:263
Depth-first Search(DFS)
There are generally two methods to write DFS algorithm, one is using recursion, another one is using stack. (reference from Wiki Pedia)Pseudocode for ...
分类:其他好文   时间:2014-06-13 08:39:34    阅读次数:218
Leetcode: Letter Combinations of a Phone Number
像这种DFS的题目,常见的写法无外乎两种,使用recursion, 或者用Stack。本文采用了stack的方式。做完后积累的经验有:像这种在一个ArrayList里面罗列可能的path的题目,recursion的参数一般包括:包含最终结果的集合(ArrayList),input(String),递...
分类:其他好文   时间:2014-06-13 08:34:10    阅读次数:220
poj 1691 Painting A Board(dfs,拓扑排序)
http://poj.org/problem?id=1691 大致题意:给出n个矩形,其参数有左上角顶点坐标,右下角顶点坐标以及该矩形所涂颜色。规定是涂当前矩形当且仅当它上面的矩形都已经被涂了色。若当前涂的颜色和上一个所涂的不同,就要换一种颜色的刷子。问应该按怎样的顺序给这n个矩形涂色使换的刷子总数最少。 思路:显然涂色是有先后顺序的,就很容易想到拓扑排序。那么首先根据矩形相交...
分类:其他好文   时间:2014-06-10 14:09:15    阅读次数:198
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!