
DFS/BFS
文章平均质量分 78
紫杉丶
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
BFS/DFS算法介绍与实现
广度优先搜索(Breadth-First-Search)和深度优先搜索(Deep-First-Search)是搜索策略中最经常用到的两种方法,特别常用于图的搜索.其中有很多的算法都用到了这两种思想,比如:Dijkstra单源最短路径算法和Prim最小生成树算法都采用了和宽度优先搜索类似的思想。 BFS的思想: 从一个图的某一个顶点V0出发,首先访问和V0相邻的且未被访问过的顶点V1、V2、转载 2015-02-05 20:53:08 · 910 阅读 · 0 评论 -
POJ 3083 Children of the Candy Corn(BFS + DFS)
优先左转 优先右转 两点最短 #include #include #include #include #include #include #include using 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 · 436 阅读 · 0 评论 -
HDU 1242 Rescue (BFS+优先队列)
从天使的位置开始,直到找到r,优先队列每次选择最短时间的路 #include #include #include #include #include #include using 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 · 345 阅读 · 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 · 298 阅读 · 0 评论 -
HDU 4634 Swipe Bo (BFS+状压)
哎,学到了~!@~!@ //#pragma comment(linker, "/STACK:102400000,102400000") #include #include #include #include #include #include #include using namespace std; const int M = 60005; const int INF = 1e10; //原创 2015-08-09 18:43:45 · 635 阅读 · 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 · 376 阅读 · 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 · 326 阅读 · 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 · 313 阅读 · 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 · 307 阅读 · 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 · 307 阅读 · 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 · 342 阅读 · 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): 1519 Problem Description A while ago原创 2015-03-07 18:54:47 · 340 阅读 · 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 · 361 阅读 · 0 评论 -
HDU 1045 Fire Net(DFS)
Fire Net Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6948 Accepted Submission(s): 3932 Problem Description Suppose that we hav原创 2015-02-09 21:08:04 · 327 阅读 · 0 评论 -
HDU 3278 Catch That Cow(简单bfs)
#include #include using namespace std; #define M 100001 #define INF 10000000 struct POINT { int pos; int step; } now, next; int n, k; queueQ; bool visited[M]; int main() { int bfs(原创 2015-02-09 20:06:11 · 481 阅读 · 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): 2580 Problem Description 可怜的公主原创 2015-02-07 20:38:20 · 433 阅读 · 0 评论 -
HDU 1241 Oil Deposits(深搜/DFS)
这题挖石油算是最基础的dfs了,入门学习可以看看,代码也是简单易懂,深入人心。 Oil Deposits Time Limit: 2000/1000 MS (Java/Others) M原创 2015-02-07 12:31:29 · 403 阅读 · 0 评论 -
POJ 2676 Sudoku (DFS)
数独,开三个标记,直接暴力,400多mS还是可以接受的 #include #include #include #include #include #include #include using namespace std; typedef long long LL; const int INF = 0x3f3f3f3f; const int M = 1010; int vish[15][15]原创 2015-10-30 14:22:46 · 399 阅读 · 0 评论