POJ 2394 Dijkstra】的更多相关文章

题意: 思路: 裸的Dijkstra 爆敲一发模板 //By SiriusRen #include <queue> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define N 2222 int f,p,c,m,xx,yy,zz,w[N],v[N],next[N],first[N],tot,dis[N],vis[N],ans,s[N]; str…
http://poj.org/problem?id=2387 一个dijkstra的模板题 #include <stdio.h> #include <string.h> #define inf 999999; ][ ]; ]; int m,n; void dijkstra() { ],k,Min; ]; ; i <= n ; i++) //对d[i]进行初始化 { mark[ i ] = false; d[ i ] = graph[ ][ i ]; } ; i <= n…
http://poj.org/problem?id=1062 一个中文题,一个多月之前我做过,当时我是用搜索写的,不过苦于卡在无法确定等级关系,所以就错了. 看了别人的博客后,我还是不是很理解所谓的枚举等级是怎样枚举,因为我觉得在递归的时候,我真的不知道怎么枚举等级. 然后今天在看到了一个人写的,枚举等级怎么枚举,我才发现我用那个搜索写的话,我还是有问题.所以我就用这个新学的dijkstra写 所谓的枚举等级,就是以每一个等级都视为最低等级来进行枚举. 比如等级限制1,而那个酋长的等级是3,那么…
题目链接:http://poj.org/problem?id=2253 题意: 给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通路的元素都是这条通路中前后两个点的距离,这些距离中又有一个最大距离. 现在要求求出所有通路的最大距离,并把这些最大距离作比较,把最小的一个最大距离作为青蛙的最小跳远距离. 思路: j从1,2,两条路中选取较小者,而1这条路,是s—>k—>j的最大步伐. #include <stdio.h&g…
题目链接:http://poj.org/problem?id=1797 题意:从路口1运货到路口n,最大的运货重量是多少?题目给出两路口间的最大载重. 思路:j加到s还是接到K下面,取两者的较大者,而使得载重量较大,而接到k下面,载重量是dis[k]和maps[k][j]的较小者. #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define INF 0x…
hdu 2544  求点1到点n的最短路  无向图 Sample Input2 1 //结点数 边数1 2 3 //u v w3 31 2 52 3 53 1 20 0 Sample Output32 堆优化Dijstra模板 # include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmath> # include &…
题目链接:http://poj.org/problem?id=2662 思路:首先路径的选择,如果B点到终点的距离比A点到终点的最短距离短,那么就从A走到B,换句话说,就是每次都是择优选择更靠近终点的点.于是我们可以从终点2跑一次Dijkstra,求出每个点到终点的最短距离,然后就是从起点1开始记忆化搜索,如果满足上面条件的,就dfs. #include<iostream> #include<cstdio> #include<cstring> #include<a…
Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 32824   Accepted: 11098 Description Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessi…
Description During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large bag of candies and had flymouse distribute them. All the kids loved candies very much and ofte…
题目链接 :http://poj.org/problem?id=3268 Description One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (one-way roa…