![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构:BFS
文章平均质量分 73
skajre
这个作者很懒,什么都没留下…
展开
-
uva 816 Abbott's Revenge
#include#include#include#include#includeusing namespace std;struct Node{ int r,c,dir; Node(int r=0,int c=0,int dir=0): r(r),c(c),dir(dir) {};};const int maxn=100;const char *dirs="NES原创 2016-05-26 09:22:05 · 235 阅读 · 0 评论 -
UVA 11624 Fire!(BFS)
预处理一下每个点的着火事件。#include#include#include#include#includeusing namespace std;const int maxn=1000+5;char map[maxn][maxn];int fire[maxn][maxn],vis[maxn][maxn];int r,c;int sx,sy;int dx[4]={-1,0,1原创 2016-11-09 16:07:03 · 233 阅读 · 0 评论 -
POJ 1475 Pushing Boxes(嵌套BFS)
从输出中可以看出箱子和人的移动相继输出,就可以想到是嵌套bfs,另外写的时候需要注意细节。//// main.cpp// Richard//// Created by 邵金杰 on 16/8/26.// Copyright © 2016年 邵金杰. All rights reserved.//#include#include#include#includeusin原创 2016-08-26 22:32:22 · 397 阅读 · 0 评论 -
POJ 1376 Robot(BFS)
用A*写了一天,没写出来,没办法只能写BFS了。#include#include#include#includeusing namespace std;struct node{ int x,y,t,dir;};const int maxn=100;int vis[maxn][maxn][4];int dx[4]={-1,0,1,0};int dy[4]={0,1,0原创 2016-08-24 17:26:52 · 220 阅读 · 0 评论 -
POJ 1077(HDU 1043)Eight(八数码DBFS)
//// main.cpp// Richard//// Created by 邵金杰 on 16/9/11.// Copyright © 2016年 邵金杰. All rights reserved.//#include#include#include#include#includeusing namespace std;const int maxn=4000原创 2016-09-13 07:49:37 · 219 阅读 · 0 评论 -
POJ 1729 Jack ans Jill(bfs)
每次扩展最多可以扩展出16个结点,搞清楚这个就可以了,其它理解不难。不过自己想还是想不出来,看的时候不下看懂了,还是要多想啊。//// main.cpp// Richard//// Created by 邵金杰 on 16/8/31.// Copyright © 2016年 邵金杰. All rights reserved.//#include#includ原创 2016-08-31 16:23:17 · 547 阅读 · 0 评论 -
POJ 1077 Eight(bfs八数码问题)
//// main.cpp// Richard//// Created by 邵金杰 on 16/8/30.// Copyright © 2016年 邵金杰. All rights reserved.//#include#include#include#includeusing namespace std;const int maxn=400000;int原创 2016-08-30 19:41:55 · 287 阅读 · 0 评论 -
HDU 5876 Sparase Graph(补图上的bfs)
//// main.cpp// Richard//// Created by 邵金杰 on 16/9/11.// Copyright © 2016年 邵金杰. All rights reserved.//#include#include#include#include#includeusing namespace std;const int maxv=2000原创 2016-09-11 08:55:52 · 196 阅读 · 0 评论 -
百练 4115 鸣人和佐助
#include#include#include#include#includeusing namespace std;const int maxn=200+10;int m,n,t,xm,ym,xz,yz;char s[maxn][maxn];int vis[maxn][maxn][maxn];struct node{ int x,y,t,steps; nod原创 2016-07-21 21:32:37 · 641 阅读 · 0 评论 -
百练 4116 拯救行动
#include#include#include#include#includeusing namespace std;const int maxn=200+5;char p[maxn][maxn];int n,m,xm,ym,xw,yw;int vis[maxn][maxn];struct node{ int l,x,y; int steps; nod原创 2016-07-21 09:47:34 · 555 阅读 · 0 评论 -
POJ 3278 Catch That Cow
#include#include#include#include#includeconst int maxn=200000+10;int f[maxn],vis[maxn];using namespace std;int main(){ memset(f,0,sizeof(f)); int n,k,ans,i,j,h; scanf("%d%d",&n,&k原创 2016-07-20 22:17:49 · 158 阅读 · 0 评论 -
HDOJ 1195 Open the Lock bfs 双向bfs
bfs和双向bfs效率对比bfs代码#include#include#include#includeusing namespace std;int vis[10100];struct node{ int num,dist;};void change(int num[4],int num1){ num[0]=num1/1000; num[1]=num原创 2016-06-08 22:21:55 · 278 阅读 · 0 评论 -
八数码问题 bfs
#include#include#includeusing namespace std;const int maxn=1000000;const int hashsize=100003;int head[maxn],Next[maxn];typedef int State[9];State st[maxn],goal;int dist[maxn];int dx[4]={0,0,原创 2016-06-07 19:22:18 · 354 阅读 · 0 评论 -
邻接表的bfs遍历
//输入样例/* 5 0 AB AD AC CD BE DE *///输出/* Please Input the edge x-->y:AB AD AC CD BE DE A 1 2 3 B 0 4 C 0 3 D 0 2 4 E 1 3 *///dfs测试数据/* 8 0 Please Input the edge x-->y:AB原创 2016-05-06 18:44:10 · 782 阅读 · 0 评论 -
UVA 10047 The Monocycle(BFS)
#include#include#include#include#includeusing namespace std;const int maxn=25+5;struct node{ int x,y,d,c,t;};int dx[4]={-1,0,1,0};int dy[4]={0,-1,0,1};char map[maxn][maxn];int vis[maxn原创 2016-11-09 17:28:48 · 236 阅读 · 0 评论