Road Construction

Source: ICPC Jakarta 2019

  1. Read the problem and summarise the task requirements.
  2. This graph has n vertices and n edges and is connected. Describe the structure of such a graph, and identify what subsets of roads could be built.

We know a lot about connected graphs with n − 1 edges. Let’s try to do the problem with this change in constraints.

  1. If there were n − 1 edges instead, what would the structure of the graph be?
  2. Design an algorithm to allocate the K workers to the n − 1 roads, obeying the constraints on materials.

  3. Analyse the time complexity of your algorithm and estimate its running time.
  4. To improve your algorithm, notice that two workers who use the same material are effectively identical!

Now, we can return to the original problem.

  1. Recall from question 2 above that there are some roads that must be built, and others from which only some roads should be built.
  2. Implement this algorithm in code.
  3. Submit your program for judging!