Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div 2 E

Directed graph on vertices 0 to 6 with positive weights (u→v (w)): 3→4 (1), 6→5 (4), 4→3 (2), 4→6 (3), 3→6 (4), 1→3 (3), 3→2 (2), 5→1 (3), 2→1 (1), 5→3 (3), 6→3 (3), 0→5 (4), 1→4 (2), 6→0 (1). The shortest distance from 0 to 6 is 11. 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 6 strictly larger?

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

Correct answer: D. 2

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic