Skip to content
Back to libraryPart 3 · Graphs and dynamic programming

3.3Shortest paths

Before you start

It helps to have read 3.1 Graph search: BFS and DFS and 1.2 Complexity and limits. Overall level: Intermediate.

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.

  1. 1Directed travel timesFind shortest distances from vertex 1 to all vertices of a directed nonnegative-weight graph. Print -1 for unreachable vertices.ApplyNot started
  2. 2Cheapest undirected routeFind the minimum cost from vertex 1 to vertex n in an undirected nonnegative-weight graph. Print -1 if unreachable.ConnectNot started
  3. 3All-pairs travel deskAnswer minimum-cost queries between pairs of vertices in a small undirected nonnegative-weight graph. Print -1 for an unreachable pair.ReasonNot started
  4. 4One discounted edgeFind the cheapest directed route from 1 to n if you may discount at most one traversed edge of weight w to floor(w/2). The discount is optional. Print -1 if no route exists.StretchNot started

Read the lesson