Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional

Connected undirected weighted graph on vertices A, B, C, D with edges A–B (6), A–C (1), A–D (1), B–C (3), B–D (6), C–D (4). Among all spanning trees whose total weight is strictly greater than the minimum spanning tree weight, what is the smallest possible total weight?

  1. A. 8
  2. B. 5
  3. C. 6
  4. D. 9

Correct answer: A. 8

The minimum spanning tree weighs 5; the true second value is 8, found only by enumerating trees. Swapping just one MST edge for the cheapest non-tree edge is the tempting shortcut that misses it.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic