题意: 你从家往学校赶,可以用步行和乘坐地铁这两种方式,步行速度为10km/h,乘坐地铁的速度为40KM/h.输入数据的第一行数据会给你起点和终点的x和y的坐标.然后会给你数目不超过200的双向地铁线路的站点,你可以从一个站点乘坐地铁到下一个站点,你可以在同一线路上乘坐地铁经过不同的站点,在不同线路的站点之间,你只能用步行的方式.让你求利用你可以利用的方式,求解到校花费的最短时间. 思路: 基础最短路径问题,Dijkstra算法可以解决.需要特别注意以下输入数据的方式,这道题目没有很明显的输入结…
POJ 2502 Subway / NBUT 1440 Subway / SCU 2186 Subway(图论,最短距离) Description You have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get to walk and take the subway.…
做这道题的动机就是想练习一下堆的应用,顺便补一下好久没看的图论算法. Dijkstra算法概述 //从0出发的单源最短路 dis[][] = {INF} ReadMap(dis); for i = 0 -> n - 1 d[i] = dis[0][i] while u = GetNearest(1 .. n - 1, !been[]) been[u] = 1 for_each edge from u d[edge.v] = min(d[edge.v], d[u] + dis[u][edge.v]…
Warm up 虽然网上题解这么多,感觉写下来并不是跟别人竞争访问量的,而是证明自己从前努力过,以后回头复习参考! 题意:n个点由m条无向边连接,求加一条边后桥的最少数量. 思路:如标题,tarjan算法求出所有的桥,然后连通的缩成点,用桥连接这些点,很容易发现这是一颗生成树,我们再加一条边必然成环,要使得桥的数量最少,就得使得这个环中的边最多.于是找这棵树最长的一条链.即树的直径.然后桥的数量减去直径既是答案.为什么不用加一呢,因为加的那条边使得成环不算桥. 总结:此题做了两天,如果全力去做的…
Subway Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6689   Accepted: 2176 Description You have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get…
<题目链接> 题目大意: 某学生从家到学校之间有N(<200)条地铁,这个学生可以在任意站点上下车,无论何时都能赶上地铁,可以从一条地铁的任意一站到另一条地跌的任意一站,学生步行速度10km/h,地铁速度40km/h,给出学生家和学校以及每条地铁的站点坐标,求学生从家到学校的最短时间. 解题分析:题目的难点在于建图,由于输入的点最多200个,并且所有点之间的距离都要考虑,所以用邻接矩阵存图,注意速度的单位是km/h,而路程的单位是m,并且要将地铁站点之间与普通点之间的距离区分,存好图后,…
Description You have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get to walk and take the subway. Because you don't want to be late for class, you want to know…
题目传送门 题意:列车上行驶40, 其余走路速度10.问从家到学校的最短时间 分析:关键是建图:相邻站点的速度是40,否则都可以走路10的速度.读入数据也很变态. #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> #include <queue> using namespace std; const int N = 2e2 + 5; const i…
Subway Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6692   Accepted: 2177 Description You have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get…
Subway 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/L Description You have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get to walk and take the s…