![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
bfs
文章平均质量分 79
RIPwangh
山东理工大学本科学生
展开
-
数据结构实验图论一:基于邻接矩阵的广度优先搜索遍历
题目描述给定一个无向连通图,顶点编号从0到n-1,用广度优先搜索(BFS)遍历,输出从某个顶点出发的遍历序列。(同一个结点的同层邻接点,节点编号小的优先遍历)输入输入第一行为整数n(0对于每组数据,第一行是三个整数k,m,t(0<k<100,0<m<(k-1)*k/2,0< t<k),表示有m条边,k个顶点,t为遍历的起始顶点。下面的m行,每行是空格隔开的两个整数u,v,表示一原创 2015-06-10 20:33:10 · 881 阅读 · 0 评论 -
Catch That Cow--poj3278
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 N (0 ≤ N ≤ 100,0原创 2015-06-14 10:03:42 · 426 阅读 · 0 评论 -
poj-2049-Finding Nemo-BFS
Nemo is a naughty boy. One day he went into the deep sea all by himself. Unfortunately, he became lost and couldn't find his way home. Therefore, he sent a signal to his father, Marlin, to ask for hel原创 2015-08-06 08:46:40 · 626 阅读 · 0 评论 -
poj-2251-Dungeon Master-BFS
题意:从S到E,一个三维的BFS可以解决,多一维,可以这样去理解,二维相当于一个平面,而三维的相当于一栋楼房,只是在z上多了几个平面而已另外,第一次用队列写BFS好开心,以前都是模拟队列,也是醉了16ms#include#include#include#include#include#includeusing namespace std;int dx[]= {原创 2015-08-18 16:53:20 · 444 阅读 · 0 评论 -
poj - 1426-Find The Multiple-BFS
题意:给你一个数n,让你找到一个由0,1构成的n的倍数思路:姿势对了,就过了1.0#include#include#include#include#include#includeusing namespace std;long long bfs(int n){ queuep; while(!p.empty()) { p.pop原创 2015-08-18 19:47:08 · 618 阅读 · 0 评论 -
poj-3126-Prime Path-BFS
题意: 给你两个素数,n,m; 问你能够最少几步把n变成m; 变的规则: 每次能够变一位数字,要求变完,仍然是素数; n,m都是4位数思路: BFS,先用素数筛把10000都筛出来,然后用BFS,对个十百千位的数字去枚举(千位不能是0)16ms#include#include#include#include#include#includeusing原创 2015-08-19 09:20:32 · 484 阅读 · 0 评论