Subway POJ - 2502 spfa】的更多相关文章

#include<cstdio> #include<cmath> #include<cstring> #include<cstring> #include<iostream> #include<queue> using namespace std; ; const double INF=0x3f3f3f3f; int k,l; struct node { double x,y; int num; } s[N]; bool st[N];…
题目链接: http://poj.org/problem?id=2502 题目大意: 你刚从一个安静的小镇搬到一个吵闹的大城市,所以你不能再骑自行车去上学了,只能乘坐地铁或者步行去上学.因为你不想迟到,所以你想知道自己多长时间能到达学校,你步行的速度是 10km/h, 地铁的速度是40km/h, 假如你是幸运的,你刚到地铁就有一辆地铁行驶过来, 你马上就可以乘坐, 任意的一个地铁你可以乘坐多次,若果你愿意你可以换乘不同的地铁,所有的地铁都是两个方向的. 输入: 输入首先包含两个坐标,表示你家的坐…
题意:在一个城市里,分布着若干条地铁线路,每条地铁线路有若干个站点,所有地铁的速度均为40km/h.现在你知道了出发地和终点的坐标,以及这些地铁 线路每个站点的坐标,你的步行速度为10km/h,且你到了地铁的任意一个站之后就刚好有地铁出发.问你从出发点到终点最少需要多少时间. ////////////////////////////////////////////////////////////////////// 有很多站点,给的数据只是一条条线路,所以需要先预处理数据,增加任意两点人走需要的…
题意:给出地铁线  起点和 终点  坐地铁速度为v2  走路为v1 求起点到终点的最短距离  (答案需要四舍五入这里坑了好久) 拿给出的地铁站点 和起点终点建边即可  然后跑个迪杰斯特拉 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; ; ; int n; +; double dist[maxn]; double cost[m…
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]…
L - Subway(最短路spfa) 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…
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 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…
Subway Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4928   Accepted: 1602 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…