Presentation is loading. Please wait.

Presentation is loading. Please wait.

Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (1) d091: Urban Transport System Po-Lung Chen Team Dont Block Me, National Taiwan.

Similar presentations


Presentation on theme: "Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (1) d091: Urban Transport System Po-Lung Chen Team Dont Block Me, National Taiwan."— Presentation transcript:

1 Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (1) d091: Urban Transport System Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

2 Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (2) Problem Description (1/2) Given information of subway lines and bus lines. For each query find the minimum time traveling from source station to the destination station.

3 Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (3) Problem Description (2/2) Every bus line is numbered from 1 to 99. Every subway line is numbered from ‘A’ to ‘Z’. The number of stations on each line. The average transfer and waiting time: From To BusSubway Bus5 min10 min Subway5 min10 min

4 Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (4) 1 32 6 5 7 Input Specification 1 L 36 2 1 3 5 3 2 3 L K 3 5 7 6 6 3 3 3 5 1 Q 1 2 Q 1 7 E The number of test cases. Bus line #36, 3 stops Bus line #36, 3 stops Subway line #11, 4 stops (6->3->5->7) Subway line #11, 4 stops (6->3->5->7) End of queries 2 Queries: 1->2? 1->7?

5 Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (5) Graph Model We view each as a node. If a bus/subway line (line number ) passes from station A to station B, an edge is created with its weight equals the time this bus/subway travel from A to B. If two bus/subway line (line number ) passes same station A, then an edge created with its cost 5 or 10 according to the average waiting time.

6 Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (6) Solution Once we constructed the graph, for each query just find the shortest path from source station (with any possible bus/subway line number) to destination. We can use Dijkstra’s algorithm to solve this problem. Moreover, we can use adjacent lists to store the information of nodes and edges on the graph.

7 Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (7) Analysis The number of nodes on the graph is equal to the sum of number of stations over all bus/subway lines, which is at most. The degree of each node is at most. Apply Dijkstra’s Algorithm with a heap we can solve this problem in. With a Fibonacci heap (NOT recommended), we can achieve the time complexity.

8 Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (8) Finally… Thanks for your attention!


Download ppt "Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (1) d091: Urban Transport System Po-Lung Chen Team Dont Block Me, National Taiwan."

Similar presentations


Ads by Google