Editorial for DMOPC '20 Contest 2 P3 - Roadrollification
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
Bruteforce the answer by trying every edge and doing graph traversals or topological sorts to see if roadrollifying that edge yields the best answer.
Time complexity:
Subtask 2
Perform two topological sorts: one directed along the given edge directions, and one with reversed edge directions. During the topological sorts, keep track of how many people are able to enter into this node from any other node (i.e. for any node
We now note that if there was no need to bidirectionalize an edge, the answer would be given by
The number of connection increases that result from the roadrollification of an edge
Now the answer is given simply by
Time complexity:
Comments