码迷,mamicode.com
首页 >  
搜索关键字:DFS Troubleshooting    ( 10753个结果
poj 1088 滑雪 dp
dp[i][j]表示从i,j开始的最长路径,记忆化搜索一下。#include #include #include using namespace std;#define maxn 120int dp[maxn][maxn],map[maxn][maxn];int r,c;int dfs(int i,...
分类:其他好文   时间:2014-07-13 23:46:25    阅读次数:259
ZOJ2165 简单DFS搜索
1 #include 2 #include 3 #include 4 #include 5 #define MAXN 25 6 using namespace std; 7 int h,w; 8 int ans; 9 int dir[4][2]={-1,0,1,0,0,-1,0,1};10 cha....
分类:其他好文   时间:2014-07-13 20:30:45    阅读次数:215
UVa539
The Settlers of Catan题意:求最长路径#include #include int maxstep;int s[100][100];int n, m;void dfs(int v, int c){ int i; if(maxstep < c) maxste...
分类:其他好文   时间:2014-07-13 20:05:02    阅读次数:181
20140710 loop-I
考试的时候写的dfs找自环然后求平均值当时感觉复杂度不是太高结果Wa和T了一些后只有40分。。。正解是二分答案再将所有边减去答案后用SPFA找有无负环即可 1 #include 2 #include 3 #include 4 using namespace std; 5 #define N 6...
分类:其他好文   时间:2014-07-13 00:47:36    阅读次数:293
HDU - 4734 F(x) (2013成都网络赛,数位DP)
题意:求0-B的满足 思路:数位DP,记忆化搜索 #include #include #include #include using namespace std; int A, B; int dp[20][200000]; int bit[20]; int dfs(int cur, int num, int flag) { if (cur == -1) return num ...
分类:其他好文   时间:2014-07-13 00:02:35    阅读次数:338
HDU-4643-GSM(DFS)
Problem Description Xiao Ming is traveling around several cities by train. And the time on the train is very boring, so Xiao Ming will use the mobile Internet. We all know that mobile phone receives ...
分类:其他好文   时间:2014-07-12 21:28:48    阅读次数:197
POJ 1979 Red and Black【深度优先搜索】
题目链接:http://poj.org/problem?id=1979 题目大意:一个矩形的房间地板被分为w*h个小块,每一个小块不是红的就是黑的,你首先站在一个黑色小块上,你只能朝你的四个方向(上下左右)移动,且不能到达红色的小块上,问你最多能到达多少个小块。 很简单的dfs深度优先搜索 没搜索过一个格子,将该格子设置为红色,之后的搜索就不会再搜索到该格子,就不会造成重复,因为该题有很多数...
分类:其他好文   时间:2014-07-12 18:44:03    阅读次数:169
poj 1274The Perfect Stall
第一次接触二分图匹配。 这题是一个匈牙利算法的模板题直接套就行。 题意是  给你奶牛和谷仓的个数a和b,接下来a行是奶牛喜欢去的谷仓。第一个是谷仓个数,接下来是谷仓编号。 这里我们把行当奶牛,列当谷仓。 在套模板。。ok;#include #include int map[1005][1005]; int a,b,link[1005],use[1005]; int dfs(int cap...
分类:其他好文   时间:2014-07-12 18:31:19    阅读次数:245
汉若塔系列续:汉诺塔VIII、汉诺塔IX、汉诺塔X。
汉诺塔VIII,在经典汉若塔问题上,问n个盘子的情况下,移动m次以后,是什么状态。 我的思路:本质还是dfs,但是用m的值来指引方向,每搜一层确定第i个盘子在哪个塔,o(n)的算法,看图说明:...
分类:其他好文   时间:2014-07-12 18:11:47    阅读次数:214
HDU 1254 推箱子
一个很有意思的 BFS+DFS。附 数据。 本来今天的任务是多重背包,结果为了帮别人找WA点,自己也坑在这道题上了。 最好想了一组自己都没过的数据……果断换思路了。 以箱子为起点做BFS找最短。每次DFS判断人能不能移动到箱子的后面。 开始就我写一个BFS,什么数据都过了。这组过不了 1 7 4 0 0 0 0 0 0 1 0 0 2 0 3 1...
分类:其他好文   时间:2014-07-12 16:57:02    阅读次数:214
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!