书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

随笔分类 -  C BFS

BFS最短路径的记录
摘要:在网上看到了一个记录BFS最短路径的方法,个人觉得相当的牛B,所以就将它记录下来了。题目:http://acm.hdu.edu.cn/showproblem.php?pid=1026这个题目比较简单,就不说题意了。直接上代码:View Code #include "iostream"#include "cstring"#include "cstdio"#include "algorithm"#include "queue"using namespace std;#define MAX 10000 阅读全文

posted @ 2012-04-28 16:51 More study needed. 阅读(713) 评论(0) 推荐(0) 编辑

TopoSort(拓扑排序)
摘要:其实说白了,拓扑排序就是一个广度优先搜索。拓扑排序的方法如下: (1)从有向图中选择一个没有前驱(即入度为0)的顶点并且输出它. (2)从网中删去该顶点,并且删去从该顶点发出的全部有向边. (3)重复上述两步,直到剩余的网中不再存在没有前趋的顶点为止.本题目是采用的邻接表存储方法。具体的实现是用vector数组。题目:HDU 1285http://acm.hdu.edu.cn/showproblem.php?pid=1285View Code #include "iostream"#include "vector"#include "queue 阅读全文

posted @ 2012-04-11 18:36 More study needed. 阅读(949) 评论(0) 推荐(0) 编辑

BFS寻求最短距离
摘要:题目:http://acm.swust.edu.cn/oj/problem/4/这是一道简单的题目,但是可以说明问题了。View Code #include "iostream"#include "string"#include "cstdio"#include "cstring"#include "algorithm"#include "queue"using namespace std;char Map[105][105];int Used[105][105];int D 阅读全文

posted @ 2011-12-01 12:14 More study needed. 阅读(277) 评论(0) 推荐(0) 编辑

BFS解决POJ 2243
摘要:DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonally and the maze is surrounded by solid 阅读全文

posted @ 2011-09-23 22:40 More study needed. 阅读(209) 评论(0) 推荐(0) 编辑

BFS解决POJ 2386
摘要:DescriptionDue to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water ('W') or dry land ('.'). Farmer John would like to figure 阅读全文

posted @ 2011-09-23 22:37 More study needed. 阅读(200) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

点击右上角即可分享
微信分享提示