https://vjudge.net/problem/HDU-2680 题意:以起始点 终点 长度 给出一个图,已知可以从w个起点出发,求从任一起点到同一个终点s的最短路径.注意是单向边.m<1e5,w<n<1000. 题解:若每个起点都dijkstra一遍时间复杂度为O((E+VlogV)*V),会TLE,想了一下,终点当成起点,反向建边就可以了 坑点:做图论习题一度因为没看到directed,directional,wa到怀疑dijkstra错了 ac代码,用的邻接表存图及优先队列d…
题目链接: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 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 /************************************************************************/ /* hdu Arbitrage dijkstra算法 题目大意:dijkstra算法,求点与点之间最短距离.因为此题的起始点不定,所以可用 反向图来求得,终点确定,从终点出发,dijkstra算法,求出其他点到终点最小距离. 本题数据量较大,用fl…
题目链接: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…
题目描述:Kiki想去他的一个朋友家,他的朋友家包括所有的公交站点一共有n 个,一共有m条线路,线路都是单向的,然后Kiki可以在他附近的几个公交站乘车,求最短的路径长度是多少. 解题报告:这道题的特点就是有多个起点,但是这并不影响我们使用迪杰斯特拉来解这道题,和前面出现的一个题目一样,我们可以增加一个虚拟的起点,然后令所有的真实的起点到这个虚拟的起点的距离都赋为1,然后就成功的转化成了单源的最短路问题了,并且是单个终点,然后用迪杰斯特拉就OK了,值得注意的就是这题里面的路线都是单向的,即所给出…
题意:小A要乘车到s车站,他有w个起始车站可选,问最短时间. 思路:用Floyd超时,Dijkstra遍历,但是也超时.仔细看看你会发现这道题目好像是多源点单终点问题,终点已经确定,那么我们可以直接转置邻接矩阵,从终点找最小的起点,转换成了单源最短路问题. 代码: #include<cstdio> #include<set> #include<cmath> #include<stack> #include<cstring> #include<…
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…
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…
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…
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): 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/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…
hdu 2680:http://acm.hdu.edu.cn/showproblem.php?pid=2680 这道题值得一提的两点:在图论中注意重边问题是必须的,有向无向也是同等重要的,如这道题 from station p to station q说的就很清楚是有向图此题如果暴力求解把每个临近的车站都作为源点走一遍,就会超时.此时的做法是在与临近的车站加上一个0,并使其的距离为零,这样就可以转化成单源点的问题 #include<iostream> #include<algorithm…
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2680 题目大意,就是一个人可以从多个起点开始出发,看到终点的最短路是多少..只有可以运用和hdu2066一样的思想,对于每个起点可以看成是跟最最开始的点之间有一条权值为0的边.可以把最开始的点记做0点.那这样就可以使用单源最短路了.之前都没有用过spfa,今天来运用了一下. 算法大致流程是用一个队列来进行维护.初始时将源加入队列.每次从队列中取出一个元素,并对所有与他相邻的点进行松弛,若某个相邻的点松…
[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) 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…
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…
传送门: 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=1599 find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2530    Accepted Submission(s): 1006 Problem Description 杭州有N个景区,景区之间有一…
find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3885    Accepted Submission(s): 1559 Problem Description 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1…
http://acm.hdu.edu.cn/showproblem.php?pid=1599 floyd找最小环. #include <cstdio> #include <cstring> #include <algorithm> #define maxn 200 using namespace std; <<; int g[maxn][maxn],dis[maxn][maxn]; int n,m,a,b,c; int main() { while(scan…
题目链接:HDU - 1599 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1,V2,....VK,V1,那么必须满足K>2,就是说至除了出发点以外至少要经过2个其他不同的景区,而且不能重复经过同一个景区.现在8600需要你帮他找一条这样的路线,并且花费越少越好. Input 第一行是2个整数N和M(N <= 100, M <= 1000),代表景区的个数和道路的条数.接下来的M行里,每行包括3个整数a…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10761    Accepted Submission(s): 3484 Problem Description One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she…