题目大意: 希望求出走出最短路的方法总数,如果次短路只比最短路小1,那也是可取的 输出总的方法数 这里n个点,每个点有最短和次短两种长度 这里采取的是dijkstra的思想,相当于我们可以不断找到更新到的最短长度来更新其他长度,保证之前的所有可取的最短长度都已经更新的情况下,这样是除了第一个点的最短路为0已知,还需要更新2*n-1次,如果从一个点的位置出发更新了其他点,那么这个位置就不再作为可更新点--这里都是暴力找最优的可更新的点--不知道如何做到像普通的dijkstra那种log级别的找点-…
4020求次短路的长度 难度级别:C: 运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 在一个地图上共有N个路口(编号分别为1到N),R条道路(道路均可以双向通行).问1号路口到N号路口的次短路长度是多少?次短路指的是比最短路长度长的次短的路径.同一条边可以经过多次. 输入 第一行包括两个整数N.R,接下来的R行,每行三个数x,y和m,表示第x号路口到第y号路口的距离是m. 输出 一个数,表示次短路的长度. 输入示例 4 41 2 1002…
题目一:一个n*n 的方格,要从左上角走到右下角,一次只能往右或往下走一步,求算法得出所有走动的方法数. 分析:对于第(i,j)个格子,只有向右走一步到达或者向左走一步到达,dp(i,j) = d(i-1,j)+dp(i,j).边界为:dp(1,j) = 1 ,  1<=j <n , dp(i,1) = 1 , 1<=i<=m. package april; import java.util.Scanner; /** * * @ClassName: Class_8 * @Descr…
题目 Tour operator Your Personal Holiday organises guided bus trips across the Benelux. Every day the bus moves from one city S to another city F. On this way, the tourists in the bus can see the sights alongside the route travelled. Moreover, the bus…
Sightseeing Time Limit: 2000MS   Memory Limit: 65536K Total Submissions:10005   Accepted: 3523 Description Tour operator Your Personal Holiday organises guided bus trips across the Benelux. Every day the bus moves from one city S to another city F. O…
http://acm.hdu.edu.cn/showproblem.php?pid=3191 求次短路的长度和个数 相关分析在这里http://blog.csdn.net/u012774187/article/details/40681515 #pragma comment(linker, "/STACK:36777216") #pragma GCC optimize ("O2") #include <cstdio> #include <cstdl…
Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31199   Accepted: 10521 Description Once upon a time there was a greedy King who ordered his chief Architect to build a wall around the King's castle. The King was so greedy, that he w…
http://poj.org/problem?id=3463 http://acm.hdu.edu.cn/showproblem.php?pid=1688 求出最短路的条数比最短路大1的次短路的条数和,基本和上题一样,最后需判断是否满足dist[t][0]+1==dist[t][1]; cnt[i][0]表示到达点i最短的路有多少条,cnt[i][1]表示次短的条数 dist[i][0]表示到达点i最短路的长度,dist[i][1]表示次短路的长度 用v去松驰u时有四种情况 (设当前dist[v…
Language: Default Sightseeing Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7766   Accepted: 2766 Description Tour operator Your Personal Holiday organises guided bus trips across the Benelux. Every day the bus moves from one city S to…
F - Sightseeing 传送门: POJ - 3463 分析 一句话题意:给你一个有向图,可能有重边,让你求从s到t最短路的条数,如果次短路的长度比最短路的长度多1,那么在加上次短路的条数. 这道题唯一要注意的就是次短路的求法 首先题目中说从起点到终点至少有一条路径,所以我们就不用考虑不可达的情况 我们先考虑如果a到b有一条边,b到c有一条边 那么a到c经过b的路程中次短路只有两种选择,一种是a到b的最短路+b到c的次短路,另一种是a到b的次短路+b到c的次短路 所以我们只需要记录次短路…