
bfs
文章平均质量分 79
Non_Cease
这个作者很懒,什么都没留下…
展开
-
poj3126
bfs代码1:自己的思路写的#include #include using namespace std;#define SIZE 10000int prim[SIZE];int dist[SIZE];int visit[SIZE];int primSize原创 2011-09-02 19:57:35 · 490 阅读 · 0 评论 -
POJ3278
//1332K 110ms#include #include using namespace std;int main(){ int a[100001],b[100001] = {0},m,n,f; queuex; cin >> m >> n; a[m原创 2011-08-21 14:05:38 · 500 阅读 · 0 评论 -
POJ3126
//代码1:376K 204ms#include #include using namespace std;#define SIZE 10000int prim[SIZE];int dist[SIZE];int visit[SIZE];int primSize;原创 2011-08-21 14:15:07 · 579 阅读 · 0 评论 -
poj3026 bfs + Prim
对每一个人'用一次BFS,记录其他人与他的距离,并建图。图建好后,用Prim求最小生成树即为答案。#include #include #include using namespace std;#define M 105#define VN 2500#define INF 1000000000int map[M][M], dist[M][M], que_x[VN], q原创 2011-11-28 10:26:10 · 1274 阅读 · 0 评论 -
poj3083 dfs + bfs
给定迷宫,深搜求向左搜索和向右搜索走出迷宫需要的步数,广搜求走出迷宫最少的步数。注意方向数组,还有横纵坐标。#include #include #include #include using namespace std;int w, h, dist[45][45];char maze[45][45];struct point { int x, y; } s;int dir原创 2012-02-25 15:10:00 · 697 阅读 · 0 评论 -
poj2251 bfs
简单广搜#include #include #include #include using namespace std;#define M 33char maze[M][M][M], tmp[M];int L, R, C, sx, sy, sz;int dist[M][M][M], step[6][3] = { {1, 0, 0}, {-1, 0, 0}, {0, 0, -原创 2012-02-27 18:47:31 · 771 阅读 · 0 评论 -
poj3414 Pots
倒水游戏,两个水壶互相倒水,直到某个水壶中的水量到达目标值,若不能到达,输出impossible这个题完全自己做出来还是感觉很开心的,因为以前在一次比赛上做过,但是没做出来,现在做出来说明还是成长了广搜,以及路径记录,最后递归输出路径。#include #include #include #include using namespace std;#define M 105原创 2012-03-02 21:10:17 · 1004 阅读 · 0 评论