码迷,mamicode.com
首页 >  
搜索关键字:zoj bfs    ( 8652个结果
POJ - 2688 Cleaning Robot
题意:求回收所有垃圾的最短路 思路:先BFS处理两个垃圾的距离,然后DFS记忆化搜索           dp[i][state]表示处理到第i个后状态是state的最短路 #include #include #include #include #include #include using namespace std; const int MAXN = 30; const in...
分类:其他好文   时间:2014-06-19 12:55:30    阅读次数:412
USACO抓牛catchcow (bfs)
这题是黄巨大出的比赛题.http://poj.org/problem?id=3278DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediatel...
分类:其他好文   时间:2014-06-19 00:58:53    阅读次数:510
spfa 判断负环 (转载)
判断给定的有向图中是否存在负环。 利用 spfa 算法判断负环有两种方法: 1) spfa 的 dfs 形式,判断条件是存在一点在一条路径上出现多次。 2) spfa 的 bfs 形式,判断条件是存在一点入队次数大于总顶点数。 代码如下:法 1 (spfa 的 dfs 形式):#include #i...
分类:其他好文   时间:2014-06-18 14:12:46    阅读次数:1042
3244: [Noi2013]树的计数 - BZOJ
Description我们知道一棵有根树可以进行深度优先遍历(DFS)以及广度优先遍历(BFS)来生成这棵树的DFS序以及BFS序。两棵不同的树的DFS序有可能相同,并且它们的BFS序也有可能相同,例如下面两棵树的DFS序都是1 2 4 5 3,BFS序都是1 2 3 4 5现给定一个DFS序和BF...
分类:其他好文   时间:2014-06-18 09:41:13    阅读次数:173
POJ 3026-Borg Maze
题目链接:Borg Maze 日,终于过了,对这题,无力多说,没想到还有那样的数据,不搜题解,我八辈子也过不了,最小生成树的最后一题! 题意:就是 S 是初始点,A是外星人,构造一条路线使他们都能到达,且路线长度最短; 思路:1.求距离->(BFS)  2. 构图(小数据:邻接矩阵) 3.建树(Prim) 水题,难的是 POJ后台。 没看别人题解,不知道加gets() ...
分类:其他好文   时间:2014-06-17 23:10:34    阅读次数:255
建图方式之“邻接链表” BFS搜索
继续校赛前的建图任务,当时只写了DFS遍历,今天把BFS也写了一下。 #include #include #include #include #include const int maxe = 10001; using namespace std; struct node{ int to,w; node *next; }*head[maxe];//he...
分类:其他好文   时间:2014-06-16 22:25:20    阅读次数:286
POJ 3278 Catch That Cow(BFS 剪枝)
题目链接:http://poj.org/problem?id=3278 这几次都是每天的第一道题都挺顺利,然后第二道题一卡一天。 = =,今天的这道题7点40就出来了,不知道第二道题在下午7点能不能出来。0 0 先说说这道题目,大意是有个农夫要抓牛,已知牛的坐标,和农夫位置。而且农夫有三种移动方式,X + 1,X - 1,X * 2,问最少几步抓到牛。 开始认为很简单的,三方向的BFS就能顺...
分类:其他好文   时间:2014-06-15 16:42:30    阅读次数:232
NYOJ 284 坦克大战 【BFS】+【优先队列】
坦克大战 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now.  What we are dis...
分类:其他好文   时间:2014-06-14 14:30:01    阅读次数:274
三分题目
zoj 3203...
分类:其他好文   时间:2014-06-14 14:01:14    阅读次数:258
NYOJ92 图像有用区域 【BFS】
//在外面加一圈非0,再广搜 #include #include using std::queue; int t, w, h, arr[962][1442]; int mov[][2] = {-1, 0, 0, 1, 1, 0, 0, -1}; queue Q; bool check(int x, int y){ if(x h + 1 || y > w + 1) return 0;...
分类:其他好文   时间:2014-06-14 10:06:32    阅读次数:276
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!