随笔分类 - BFS&DFS
摘要:---###题目链接[戳我](http://acm.hdu.edu.cn/showproblem.php?pid=5335)###题目大意$m * n$的矩阵,每个格子是`0`或者`1`,探险家初始位置是$(1, 1)$,终点位置是$(n, m)$,且只能向 上下左右四个方向走,因为从 起点到终点 ...
阅读全文
摘要:去年的比赛题目,今年才搞懂AC了===|| 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 using na...
阅读全文
摘要:题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1495有三个瓶子 A B C,每次都有6个状态A->B A->C B->A B->C C->A C->B用BFS跑一遍就行了代码: 1 #include 2 #include 3 #incl...
阅读全文
摘要:精妙,涨姿势了!!#include#include#include#define N 10100using namespace std;int pre[N],num[N],a[10];int n,m,x;void init(){ memset(pre,-1,sizeof(pre)); m...
阅读全文
摘要:就是简单的搜索题====渣渣搞了4个小时暴力寻找, 250MS==代码#include #include #include using namespace std;#define N 105struct Point{ int fx; int x, y; int step; i...
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5343比赛时候, 用BFS, 一直MLE, 坑爹啊;题意: 保安巡逻仓库, 老板在耨写仓库上装了传感器, 传感器只能记录一次, 所以只能记录第一次经过这个仓库;但是保安可能会FQ,...
阅读全文
摘要:http://www.cnblogs.com/JMDWQ/archive/2012/05/20/2510698.htmlhttp://baike.baidu.com/view/614354.htm?fr=aladdinhttp://wenku.baidu.com/link?url=UWWBEOE_q...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1180#include "cstdio"#include "cstring"#include "queue"#include "algorithm"using namespace std;int n,m, s;ch...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1728这道题和 hdu 1175 很相似,所以直接把1175这题的代码那过来修改,可是一直WA,按理说不应该WA的。。。。后来才发现,在转弯的时候,如果当前的转弯次数和上次相同,这时候也要放到队列里,因为我们不知道...
阅读全文
摘要:点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=2102AC代码 用到三维数组,第二次写的代码,因为memset(s,'*',sizeof(s));这里写错了,WA了无数次;// hdu 2102 A ji hua (xiu gai ban)#i...
阅读全文
摘要:hdu 1072题目大意就是一个人身上有一个炸弹,这个炸弹6分钟后爆炸,在迷宫中,0是墙,不能走; 1可以走, 2是开始位置,3是出口,4是炸弹充值装置,如果走到那个位置时,炸弹事件大于0,就会把、时间重置为 6 分钟(这里我开始理解错了,以为他获得了这个装置,可以随时使用,意思就是相当于增加6分钟...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1175连连看Time Limit: 20000/10000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s):...
阅读全文
摘要:http://poj.org/problem?id=1321棋盘问题Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 22332Accepted: 11084Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1010大神题解报告http://acm.hdu.edu.cn/forum/read.php?tid=6158关于剪枝,没有剪枝的搜索不太可能,这题老刘上课的时候讲过两个剪枝,一个是奇偶剪枝,一个是路径剪枝奇偶剪枝:...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2553回溯法,一直错在了标记为1,0上面,应该标记为++,这样回溯的时候才不会把别人的点还原;同时,这一题要记录下来这10个的answer,否则TLE#include#include#includeusing na...
阅读全文
摘要:深度优先搜索属于图算法的一种,英文缩写为DFS即Depth First Search.其过程简要来说是对每一个可能的分支路径深入到不能再深入为止,而且每个节点只能访问一次.举例说明之:下图是一个无向图,如果我们从A点发起深度优先搜索(以下的访问次序并不是唯一的,第二个点既可以是B也可以是C,D),则...
阅读全文

浙公网安备 33010602011771号