Practice: Shortest paths
0 of 4 solved
About these problems
Apply, Connect, Reason and Stretch describe difficulty within this topic, not an official contest rating. Open any problem in any order; reading the chapter first is optional.
- 1Directed travel timesA directed graph has n vertices, numbered 1 to n, and m edges with nonnegative weights. Find the shortest distance from vertex 1 to every vertex. Print -1 for unreachable vertices.ApplyNot started
- 2Cheapest undirected routeAn undirected graph has n vertices, numbered 1 to n, and m edges with nonnegative weights. Find the minimum cost of a route from vertex 1 to vertex n. Print -1 if vertex n is unreachable.ConnectNot started
- 3All-pairs travel deskA small undirected graph has n vertices, numbered 1 to n, and m edges with nonnegative weights. Print the minimum route cost from vertex a to vertex b for each of q queries a b, or -1 if b cannot be reached from a. The cost from a vertex to itself is 0.ReasonNot started
- 4One discounted edgeA directed graph has n vertices, numbered 1 to n, and m edges with nonnegative weights. Find the cheapest route cost from vertex 1 to vertex n if you may discount at most one edge on the route, changing its weight w to floor(w/2). The discount is optional. Print -1 if no route exists.StretchNot started