POJ 2251 Dungeon Master /UVA 532 Dungeon Master / ZOJ 1940 Dungeon Master(广度优先搜索) Description You 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 ta…
Problem Description You 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…
Dungeon Master  Descriptions: You 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…
题目大意: 在n个点 m条边的无向图中 需要运送X单位牛奶 每条边有隐患L和容量C 则这条边上花费时间为 L+X/C 求从点1到点n的最小花费 优先队列维护 L+X/C 最小 广搜到点n #include <bits/stdc++.h> using namespace std; #define LL long long #define INF 0x3f3f3f3f #define mem(i,j) memset(i,j,sizeof(i)) #define inc(i,l,r) for(int…
最少步数 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 这有一个迷宫,有0~8行和0~8列: 1,1,1,1,1,1,1,1,1 1,0,0,1,0,0,1,0,1 1,0,0,1,1,0,0,0,1 1,0,1,0,1,1,0,1,1 1,0,0,0,0,1,0,0,1 1,1,0,1,0,1,0,0,1 1,1,0,1,0,1,0,0,1 1,1,0,1,0,0,0,0,1 1,1,1,1,1,1,1,1,1 0表示道路,1表示墙. 现在输入一个道路的坐标…
用二元组$(city,fuel)$即可记录所有状态,以当前花费为关键字优先队列,开数组记录直接做即可 有一个点在于每次不用枚举所有的加油数量,只需要加一即可,因为如果在加一升更优的话又会扩展出加更多油的状态,不必枚举过多 #include<iostream> #include<cstdio> #include<queue> #include<cstring> using namespace std; ; ; int n,m,a[maxn],c; struct…
#include<bits/stdc++.h> using namespace std; ; ; char G[maxN][maxN]; ]; int n, m, sx, sy, ex, ey, ans; ][] = {{,},{,},{,-},{-,}}; struct node { int x, y, t, o; bool operator < (const node& p) const { return t > p.t; } }; void bfs() { node…
题目链接:http://acm.hrbust.edu.cn/vj/index.php?/vj/index.php?c=&c=contest-contest&cid=134#problem/7 很简单的广搜题.依然没有顺利的1A.没用优先队列.搞不清是不是还要回溯一下?[啊哈哈.我就是这么想的.] // hrbust 1621 迷宫问题II // 优先队列——广搜 // 什么时候需要回溯什么时候不需要? #include <stdio.h> #include <string…
题意:       悟空要救唐僧,中途有最多就把钥匙,和最多五条蛇,要求就得唐僧并且拿到所有种类的钥匙(两个1只拿一个就行),拿钥匙i之前必须拿到钥匙i-1,打蛇多花费一秒,问救出唐僧并且拿到所有种类的钥匙的最小花费时间. 思路:       应该两种方法吧,感觉很多都是用4维的标记,然后广搜的,我用的是3维的标记,然后优先队列广搜的,题目没啥难的,关键是读懂题,敲代码的时候细心点就行了.mark[x][y][key] 表示在x,y点是要是状态是key是否走过. #include<stdio.h…
题目 简单的3d广搜,做法类似与 hdu 的 胜利大逃亡 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> #include<queue> using namespace std; #define MAXN 32 char map[MAXN][MAXN][MAXN]; int a,b,c…