![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
DFS/BFS
文章平均质量分 80
紫杉丶
这个作者很懒,什么都没留下…
展开
-
BFS/DFS算法介绍与实现
广度优先搜索(Breadth-First-Search)和深度优先搜索(Deep-First-Search)是搜索策略中最经常用到的两种方法,特别常用于图的搜索.其中有很多的算法都用到了这两种思想,比如:Dijkstra单源最短路径算法和Prim最小生成树算法都采用了和宽度优先搜索类似的思想。BFS的思想:从一个图的某一个顶点V0出发,首先访问和V0相邻的且未被访问过的顶点V1、V2、转载 2015-02-05 20:53:08 · 854 阅读 · 0 评论 -
POJ 3083 Children of the Candy Corn(BFS + DFS)
优先左转 优先右转 两点最短#include#include#include#include#include#include#includeusing namespace std;typedef long long LL;const int INF = 0x3f3f3f3f;const int M = 1010;int dir[][2] = { 0,-1,-1,0,0原创 2015-10-26 23:03:33 · 380 阅读 · 0 评论 -
HDU 1242 Rescue (BFS+优先队列)
从天使的位置开始,直到找到r,优先队列每次选择最短时间的路#include#include#include#include#include#includeusing namespace std;typedef long long LL;const int INF = 0x3f3f3f3f;const int M = 1010;struct node{ int x, y原创 2015-10-25 09:50:28 · 306 阅读 · 0 评论 -
HDU 5379 Mahjong tree (DFS)
#pragma comment(linker, "/STACK:102400000,102400000")#include #include #include #include #include using namespace std;typedef long long LL;const long long mod = 1e9+7;const int inf = 0x3f3f3f原创 2015-08-12 13:39:41 · 276 阅读 · 0 评论 -
HDU 4634 Swipe Bo (BFS+状压)
哎,学到了~!@~!@//#pragma comment(linker, "/STACK:102400000,102400000")#include#include#include#include#include#include#includeusing namespace std;const int M = 60005;const int INF = 1e10;//原创 2015-08-09 18:43:45 · 589 阅读 · 0 评论 -
ZOJ 3865 Superbot(BFS水题)
比赛的时候题意理解错了,不想多说什么了。。水题一道,,给你四个按钮,每次你可以选择不动,左右移动按钮,按钮每P秒右移一次,,水啊#include "stack"#include "cstdio"#include "iostream"#include "cmath"#include "set"#include "sstream"#include "cctype"#原创 2015-04-13 14:53:10 · 348 阅读 · 0 评论 -
POJ 3126 Prime Path (BFS)
#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype"#include "sstream"#include "cstdlib"#include "c原创 2015-04-09 21:40:18 · 294 阅读 · 0 评论 -
ZOJ 3861 Valid Pattern Lock
全排列之后筛选。。#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype"#include "sstream"#include "cstdlib"原创 2015-04-13 15:10:44 · 285 阅读 · 0 评论 -
HDU 2612 Find a way (bfs)
简单题,,,#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype"#include "sstream"#include "cstdlib"#in原创 2015-04-07 19:28:30 · 278 阅读 · 0 评论 -
POJ 3984 迷宫问题 (bfs 水)
#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype"#include "sstream"#include "cstdlib"#include "c原创 2015-04-07 19:27:41 · 285 阅读 · 0 评论 -
HDU 1429 胜利大逃亡(续)(状压bfs)
与其他bfs不同的是这种题需要用二进制来保存钥匙这个状态,需要多用一维数组来保存。。可以通过位运算 | “拾取钥匙”, & “匹配钥匙”。#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vecto原创 2015-03-17 20:46:17 · 325 阅读 · 0 评论 -
HDU 2952 Counting Sheep
Counting Sheep Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2308 Accepted Submission(s): 1519Problem DescriptionA while ago原创 2015-03-07 18:54:47 · 318 阅读 · 0 评论 -
HDU 2128 Tempter of the Bone II(BFS)
#include "stack"#include "cstdio"#include "iostream"#include "cmath"#include "set"#include "sstream"#include "cctype"#include "string"#include "cstring"#include "algorithm"#include原创 2015-03-15 08:32:38 · 338 阅读 · 0 评论 -
HDU 1045 Fire Net(DFS)
Fire NetTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6948 Accepted Submission(s): 3932Problem DescriptionSuppose that we hav原创 2015-02-09 21:08:04 · 294 阅读 · 0 评论 -
HDU 3278 Catch That Cow(简单bfs)
#include#includeusing namespace std;#define M 100001#define INF 10000000struct POINT{ int pos; int step;} now, next;int n, k;queueQ;bool visited[M];int main(){ int bfs(原创 2015-02-09 20:06:11 · 449 阅读 · 0 评论 -
HDU 2102 A计划 (DFS)
LJ救公主,搜一遍就好,, A计划Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10660 Accepted Submission(s): 2580Problem Description可怜的公主原创 2015-02-07 20:38:20 · 410 阅读 · 0 评论 -
HDU 1241 Oil Deposits(深搜/DFS)
这题挖石油算是最基础的dfs了,入门学习可以看看,代码也是简单易懂,深入人心。 Oil Deposits Time Limit: 2000/1000 MS (Java/Others) M原创 2015-02-07 12:31:29 · 374 阅读 · 0 评论 -
POJ 2676 Sudoku (DFS)
数独,开三个标记,直接暴力,400多mS还是可以接受的#include#include#include#include#include#include#includeusing namespace std;typedef long long LL;const int INF = 0x3f3f3f3f;const int M = 1010;int vish[15][15]原创 2015-10-30 14:22:46 · 349 阅读 · 0 评论