码迷,mamicode.com
首页 >  
搜索关键字:zoj bfs    ( 8652个结果
经典图算法Java代码实践:BFS,DFS以及几种最短路径算法
public class City { String name; int id; static int idCounter = 0; public City(String name) { this.name=name; id = idCounter++; } } import java.util.ArrayList; public class Gr...
分类:编程语言   时间:2014-06-19 10:36:26    阅读次数:196
三维bfs(HUD1253胜利大逃亡)
#include #include int map[51][51][51];int v[51][51][51];int a,b,c,t11;struct node{ int x,y,z,ans;}q[200001];int jx[6]={0,0,0,0,-1,1};int jy[6]={0,0...
分类:其他好文   时间:2014-06-13 17:10:39    阅读次数:157
图的所有简单算法实现
包括邻接链表、有向无向图、带权图、增删顶点和边、查找、连通、DFS和BFS等。这只是一个最初版本,有些复杂的算法还没有实现。 package structure; //图的邻接链表的节点 public class GraphListNode { private int vertex;//图的顶点 private int weight;//边的权重 private boolean vis...
分类:其他好文   时间:2014-06-11 06:24:05    阅读次数:365
数据结构:树的BFS,树的层次遍历! 按先序遍历创建一棵树,然后以层次遍历输出。
按先序遍历创建一棵树,以层次遍历输出 样例输入 A B # D # # C E # # F # # 样例输出 LevelOrder: A B C D E F     代码: #include #include using namespace std; struct node { //表示一个树上的节点 char ch; nod...
分类:其他好文   时间:2014-06-10 15:58:02    阅读次数:295
POJ 2049— Finding Nemo(三维BFS)10/200
这个题开始不会建图,彻底颠覆以前我对广搜题的想法。想了好久, 忽然想到省赛时HYPO让我做三维BFS来着,一直没做,看到POJ计划这个题,就是三维BFS解题,就做了一下, 对于这个题。。。。实在不知道说什么好,又坑、又SB,POJ的后台数据和题目描述的完全不一样,看了DIscuss之后开始 改动代码,最后改的又臭又长,卡了整整两天。 挥挥洒洒 160行。。。。同时也是我第一次使用  三维建图+B...
分类:其他好文   时间:2014-06-10 14:20:15    阅读次数:326
迷宫最短路径问题
问题描述:给定一个迷宫和一个起点一个终点,求起点到终点的最短路径长度。Sample Input(说明:5行5列的迷宫,‘#’为墙,‘.’为路,起点为(0,3), 终点为(4,4))Sample Output11(若不可达输出-1)解答:用BFS的方法,借助一个队列实现。 1 #include 2 #...
分类:其他好文   时间:2014-06-10 09:18:08    阅读次数:258
POJ - 1376 Robot
题意:求在可以一秒沿着既定方向走1到3步和向左或右转90度的情况下,从起点到终点的最短时间 思路:坑的是这机器人还有体积,所以不能走到边界,然后就是单纯的BFS #include #include #include #include #include using namespace std; const int MAXN = 110; struct node { int x,y;...
分类:其他好文   时间:2014-06-10 07:59:51    阅读次数:256
UVA 10085(bfs+康拓展开)八数码问题
Description Problem A The Most Distant State Input: standard input Output: standard output   The 8-puzzle is a square tray in which eight square tiles are placed. The remaining ninth square ...
分类:其他好文   时间:2014-06-10 07:59:06    阅读次数:335
zoj 1454 Employment Planning
【题解】:【代码】: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define LL long long 7 using namespace std; 8 LL dp[15][100005]; 9 LL N,h,uh,...
分类:其他好文   时间:2014-06-08 20:08:41    阅读次数:261
HDU 1495 非常可乐 (BFS)
问题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1495 题目大意:一个瓶子容积s,两个杯子容积分别n,m,并且都没有刻度(不能比对噢!)。相互倒水,求平分的他们的最少倒水次数。 思路:暴力搜索吧。并且求最少,(即最优解),随意上BFS; 思考:状态,转移过程,怎么剪纸。 惨痛的debug,我不解释了。...
分类:其他好文   时间:2014-06-08 15:48:26    阅读次数:234
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!