深度优先搜索基础
mao_yi_hao
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ3009题解
《挑战》中开列的DFS习题之一; 思维难度不大,读懂并直接模拟游戏规则即可; 实际写起来坑不少,考验码程序的基本功; 屡次WA,最后好不容易肉眼揪完错兴奋地交上去发现PE,再后来发现输出时没打‘\n’。。。 #include<cstdio> #include<algorithm> #include<vector> using namespace std; const int dy[5]={-1,1,原创 2017-11-30 21:08:32 · 584 阅读 · 0 评论 -
POJ3050题解
《挑战》中开列的DFS习题之一; 要求所有解,故用DFS; 弱智的暴力DFS; 注意题目允许走回头路,与很多其它问题不同; set是维护当前解的神器,兼log级高效的查找、排序、去重于一身,搜索经典问题——八数码问题就可以用set来剪枝或曰启发,代码简洁漂亮,效率高。 #include<iostream> #include<set> using namespace std; const int dy原创 2018-02-08 19:33:58 · 305 阅读 · 0 评论 -
POJ2386题解
数水塘,DFS入门的入门,不多说了,存个代码而已。。。 #include<cstdio> using namespace std; const int dy[9]={-1,-1,-1,0,0,1,1,1}; const int dx[9]={-1,0,1,-1,1,-1,0,1}; char fld[110][110]; void dfs(int y,int x) { fld[y][x]='原创 2018-02-08 19:41:23 · 294 阅读 · 0 评论
分享