hdu-2680 Choose the best route(最短路)】的更多相关文章

题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2680 Choose the best route Description One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a ma…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2680 Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7201    Accepted Submission(s): 2350 Problem Description One day , Kiki…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2680 题目意思:实质就是给定一个多源点到单一终点的最短路. 卑鄙题---有向图.初始化map时 千万不要写成 map[i][j] = map[j][i] = X. #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; #de…
Problem DescriptionOne day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and the stations which are near Kiki…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2680 /************************************************************************/ /* hdu Arbitrage dijkstra算法 题目大意:dijkstra算法,求点与点之间最短距离.因为此题的起始点不定,所以可用 反向图来求得,终点确定,从终点出发,dijkstra算法,求出其他点到终点最小距离. 本题数据量较大,用fl…
题目描述:Kiki想去他的一个朋友家,他的朋友家包括所有的公交站点一共有n 个,一共有m条线路,线路都是单向的,然后Kiki可以在他附近的几个公交站乘车,求最短的路径长度是多少. 解题报告:这道题的特点就是有多个起点,但是这并不影响我们使用迪杰斯特拉来解这道题,和前面出现的一个题目一样,我们可以增加一个虚拟的起点,然后令所有的真实的起点到这个虚拟的起点的距离都赋为1,然后就成功的转化成了单源的最短路问题了,并且是单个终点,然后用迪杰斯特拉就OK了,值得注意的就是这题里面的路线都是单向的,即所给出…
题意:小A要乘车到s车站,他有w个起始车站可选,问最短时间. 思路:用Floyd超时,Dijkstra遍历,但是也超时.仔细看看你会发现这道题目好像是多源点单终点问题,终点已经确定,那么我们可以直接转置邻接矩阵,从终点找最小的起点,转换成了单源最短路问题. 代码: #include<cstdio> #include<set> #include<cmath> #include<stack> #include<cstring> #include<…
Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8224    Accepted Submission(s): 2706 Problem Description One day , Kiki wants to visit one of her friends. As she is liable…
题目链接: Choose the best route Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others) Problem Description   One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her frie…
http://acm.hdu.edu.cn/showproblem.php?pid=2680 Problem Description One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s tra…
Problem Description One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and the stations which are near Kik…
此题中起点有1000个,边有20000条.用链式前向星建图,再枚举起点用SPFA的话,超时了.(按理说,两千万的复杂度应该没超吧.不过一般说计算机计算速度 1~10 千万次/秒.也许拿最烂的计算机来卡时间) 有一个技巧,加一个超级源点.也就是加一个点,使得该点连通所有的起点,并且边的权值为0.这个技巧应用蛮多的.网络流.最小树形图都有题目这样做. #include<iostream> #include<cstdio> #include<cstring> #include…
http://acm.hdu.edu.cn/showproblem.php?pid=2680 Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9602    Accepted Submission(s): 3111 Problem Description One day , Kiki wants…
Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5273    Accepted Submission(s): 1680 Problem Description One day , Kiki wants to visit one of her friends. As she is liable…
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2680 题目大意,就是一个人可以从多个起点开始出发,看到终点的最短路是多少..只有可以运用和hdu2066一样的思想,对于每个起点可以看成是跟最最开始的点之间有一条权值为0的边.可以把最开始的点记做0点.那这样就可以使用单源最短路了.之前都没有用过spfa,今天来运用了一下. 算法大致流程是用一个队列来进行维护.初始时将源加入队列.每次从队列中取出一个元素,并对所有与他相邻的点进行松弛,若某个相邻的点松…
Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12442    Accepted Submission(s): 4046 Problem Description One day , Kiki wants to visit one of her friends. As she is liable…
Choose the best route Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 86   Accepted Submission(s) : 35 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description One day , Kiki…
Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7062    Accepted Submission(s): 2301 Problem Description One day , Kiki wants to visit one of her friends. As she is liable…
hdu 2680:http://acm.hdu.edu.cn/showproblem.php?pid=2680 这道题值得一提的两点:在图论中注意重边问题是必须的,有向无向也是同等重要的,如这道题 from station p to station q说的就很清楚是有向图此题如果暴力求解把每个临近的车站都作为源点走一遍,就会超时.此时的做法是在与临近的车站加上一个0,并使其的距离为零,这样就可以转化成单源点的问题 #include<iostream> #include<algorithm…
[hdu P1599] find the mincost route 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1,V2,....VK,V1,那么必须满足K>2,就是说至除了出发点以外至少要经过2个其他不同的景区,而且不能重复经过同一个景区.现在8600需要你帮他找一条这样的路线,并且花费越少越好.  Input第一行是2个整数N和M(N <= 100, M <= 1000),代表景区的个数和道路的条…
Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13229    Accepted Submission(s): 4280 Problem Description One day , Kiki wants to visit one of her friends. As she is liable…
Choose the best route Problem Description One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and the stati…
http://acm.hdu.edu.cn/showproblem.php?pid=2680 Problem Description One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend's home as soon as possible . Now give you a map of the city's tra…
这道题也是死命TLE.. http://acm.hdu.edu.cn/showproblem.php?pid=2680 /* 使用pair代替结构 */ #include <iostream> #include <cstdio> #include <queue> #include <vector> using namespace std; ; const int INF = 0x3f3f3f3f; typedef pair<int,int> pa…
题目链接 Problem Description 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1,V2,....VK,V1,那么必须满足K>2,就是说至除了出发点以外至少要经过2个其他不同的景区,而且不能重复经过同一个景区.现在8600需要你帮他找一条这样的路线,并且花费越少越好. Input 第一行是2个整数N和M(N <= 100, M <= 1000),代表景区的个数和道路的条数. 接下来的M行里…
Minimum Transport Cost http://acm.hdu.edu.cn/showproblem.php?pid=1385 Problem Description These are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is some cargo that should be delivere…
题目链接: POJ:http://poj.org/problem?id=3835 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=3268 Problem Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera with a few ships, starting a serious of voyages o…
HDU - 2290 Find the Path Time Limit: 5000MS   Memory Limit: 64768KB   64bit IO Format: %I64d & %I64u Submit Status Description Scofield is a hero in American show "Prison Break". He had broken the prison and started a big runaway. Scofield h…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1599 find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7047    Accepted Submission(s): 2736 Problem Description 杭州有N个景区,景区之间有一…
http://acm.hdu.edu.cn/showproblem.php?pid=4960 2014 Multi-University Training Contest 9 Another OCD Patient Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 181    Accepted Submission(s): 58 Pr…