Data Structures & AlgorithmsHardICPC regional · Codeforces Div 2 E

Directed graph on vertices 0 to 5 with positive weights (u→v (w)): 5→3 (2), 5→0 (3), 1→5 (1), 4→2 (3), 4→5 (4), 3→2 (3), 5→2 (2), 2→5 (1), 3→4 (1), 1→0 (4), 3→0 (4), 2→1 (1), 3→1 (4), 0→4 (2). The shortest distance from 0 to 5 is 6. How many edges e have this property: adding 1 to the weight of e, and changing nothing else, makes the shortest distance from 0 to 5 strictly larger?

  1. A. 1
  2. B. 4
  3. C. 2
  4. D. 14

Correct answer: A. 1

An edge is critical exactly when it lies on every shortest route; recomputing distances after each +1 gives 1. Counting edges on some shortest route (4) overcounts alternatives, and the edges of one route (2) is a different quantity.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic