![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
深搜DFS
文章平均质量分 78
刘da帅气
这个作者很懒,什么都没留下…
展开
-
找朋友SDUT(2779)
一开始用dfs做的 超时了然后又用了bfs才A掉的 找朋友 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 X,作为户外运动的忠实爱好者,总是不想呆在家里。现在,他想把死宅Y从家里拉出来。问从X的家到Y的家的最短时间是多少。 为了简化问题,我们把地图抽象为n*m的矩阵,行原创 2016-03-30 22:36:00 · 359 阅读 · 0 评论 -
poj 3009 Curling 2.0
Curling 2.0 只要步数超过了10||超过了之前已经存在的步数,就可以不用再继续往下找了 #include #include #include #include #include using namespace std; int n, m; int Map[30][30]; int dx[] = {0,0,1,-1}; int dy[] = {1,-1,0,0};原创 2017-04-17 20:29:11 · 324 阅读 · 0 评论 -
POJ 1321 棋盘问题
网上代码1: #include #include int n,k,vis[15],ans; char mat[15][15]; void dfs(int cur,int num) { if(num==k) { ans++; return; } for(int i=cur;i<n;i++) for(int j=0;j<n;j++) if(mat[原创 2016-08-13 20:25:32 · 200 阅读 · 0 评论 -
POJ 2488 A Knight's Journey
控制好八个方向就行,安字典序,所以~~~先列再行 代码 #include #include #include #include #include using namespace std; int step; int flag; int path[50][50]; int book[50][50]; int dx[] = {-1,1,-2,2,-2,2,-1,1}; int dy[原创 2016-08-13 16:49:05 · 189 阅读 · 0 评论 -
POJ 3083 Children of the Candy Corn
明白题意,S->E,第一个输出左偏到达的步数,第二个输出右偏到达的步数,第三个输出最短路用BFS 左偏的意思是,开始方向任意定义并且在后面都始终不会变,先看左边的格子是否能走,然后逆时针(就是从左边的第一个格子往右偏). 右偏,开始跟左一样,先看右边的格子是否能走,然后顺时针(说白了就是从右边的第一个格子往左偏), #include #include #include #include原创 2016-08-01 14:16:17 · 186 阅读 · 0 评论 -
POJ 1426 Find The Multiple dfs
输出结果有点不能理解 #include #include #include #include #include using namespace std; int n; int flag; void dfs(unsigned long long a, int k)//unsigned long long的最大值:18446744073709551615 { if(flag||k原创 2016-08-15 21:08:22 · 210 阅读 · 0 评论 -
POJ 1753 Flip Game 深搜
比POJ 2965 简单一点不用输出路径,直接上代码了#include #include #include #include #include #include using namespace std; int map[6][6]; char a[6][6]; int flag; int ans; int dx[] = {0,1,-1,0}; int dy[] = {1,0,0,-原创 2016-07-28 11:37:15 · 236 阅读 · 0 评论 -
POJ 2965 The Pilots Brothers' refrigerator 深搜
好久没敲深搜了,弱弱比较难想~~~~看了题解才做出来的#include #include #include #include #include #include using namespace std; int map[6][6]; char a[6][6]; int b[105][2]; int flag; int ans; bool check() { int i,原创 2016-07-28 10:56:53 · 194 阅读 · 0 评论 -
图结构练习——BFS——从起始点到目标点的最短步数
图结构练习——BFS——从起始点到目标点的最短步数 Time Limit: 1000MS Memory limit: 65536K 题目描述 在古老的魔兽传说中,有两个军团,一个叫天灾,一个叫近卫。在他们所在的地域,有n个隘口,编号为1..n,某些隘口之间是有通道连接的。其中近卫军团在1号隘口,天灾军团在n号隘口。某一天,天灾军团的领袖巫妖王决定派兵攻打近卫原创 2016-04-08 19:28:54 · 271 阅读 · 0 评论 -
广度优先搜索练习之神奇的电梯
广度优先搜索练习之神奇的电梯 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 有一座已知层数为n的高楼,这座高楼的特殊之处在于只能靠电梯去上下楼,所以要去到某一层要非常耽误时间,然而更悲哀的是,这座高楼的电梯是限号的,小鑫最开始的时候在1层,他想去第x层,问题是他最起码要经过多少层(包含原创 2016-04-08 19:24:54 · 462 阅读 · 0 评论 -
Catch That Cow
Catch That Cow Time Limit: 2000MS Memory limit: 65536K 题目描述 Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point原创 2016-04-06 22:36:39 · 216 阅读 · 0 评论 -
图结构练习——BFSDFS——判断可达性
图结构练习——BFSDFS——判断可达性 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 在古老的魔兽传说中,有两个军团,一个叫天灾,一个叫近卫。在他们所在的地域,有n个隘口,编号为1..n,某些隘口之间是有通道连接的。其中近卫军团在1号隘口,天灾军团在n号隘口。某一天,天灾军团的领袖原创 2016-04-05 20:46:00 · 274 阅读 · 0 评论 -
数据结构实验图论一:基于邻接矩阵的广度优先搜索遍历
数据结构实验图论一:基于邻接矩阵的广度优先搜索遍历 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 给定一个无向连通图,顶点编号从0到n-1,用广度优先搜索(BFS)遍历,输出从某个顶点出发的遍历序列。(同一个结点的同层邻接点,节点编号小的优先遍历) 输入 输入第一行为整数n原创 2016-04-05 20:30:19 · 280 阅读 · 0 评论 -
sdut 3469 深度优先搜索练习之神奇的矩环
题意很简单 判断一个图中有没有环,只要是遇到一个点曾经走过并且和上一个点相同,即可求出解,但是要注意的是某个点走过之后,这个点的下一个点不能再是 上一个点,所有我用了一个dir方向判断了一下, 深度优先搜索练习之神奇的矩环 #include #include #include #include #include using namespace std; char Map[30原创 2017-04-16 13:11:53 · 516 阅读 · 0 评论