Each test case starts with a line containing three integers V, E, and Q, denoting the number of vertices, edges, and queries, respectively. Note that vertices are identified with integers from 0 to V-1. E lines follow, each containing three integers s_i, d_i, l_i, denoting the source vertex, destination vertex, and latency; these three integers describe the ith edge. Q lines follow, each containing a single vertex q_i, for which you must determine the total latency T_i of the shortest path from vertex 0 to vertex q.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Our goal in this problem is to determine the “lowest latency routes” starting from your location. The internet in this problem is modeled by a graph, with vertices corresponding to other clients or servers, and edges representing the links between clients/servers. Each edge is not undirected, i.e., the links are unidirectional. At the same time, each link adds a constant latency if you use the link in your routes. Note that if you need to communicate with your own client, then the latency is 0. We represent your location as the vertex 0. Your goal is to determine the total latency it would take if you used the shortest path route from your location to any other client/server in the network.

Input Format

Each test case starts with a line containing three integers V, E, and Q, denoting the number of vertices, edges, and queries, respectively. Note that vertices are identified with integers from 0 to V-1. E lines follow, each containing three integers s_i, d_i, l_i, denoting the source vertex, destination vertex, and latency; these three integers describe the ith edge. Q lines follow, each containing a single vertex q_i, for which you must determine the total latency T_i of the shortest path from vertex 0 to vertex q.

Constraints

2≤V≤100,000

V≤E≤1,000,000

1≤Q≤V

0≤s_i,d_i

Output Format

For each query vertex q_i, you must output a line containing q_i and T_i. If q_i is not reachable, output “None” instead.

 

Sample Input 0
7 11 7
035
0 1 7
1 2 8
147
13 9
3 4 15
356
245
458
469
5 6 11
OHHHMMN & SOHNM & ST
2
6
7
Sample Output 0
0:0
1: 7
2: 15
3: 5
4: 14
5: 11
6: 22
Transcribed Image Text:Sample Input 0 7 11 7 035 0 1 7 1 2 8 147 13 9 3 4 15 356 245 458 469 5 6 11 OHHHMMN & SOHNM & ST 2 6 7 Sample Output 0 0:0 1: 7 2: 15 3: 5 4: 14 5: 11 6: 22
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY