Editorial for IOI '10 P6 - Traffic Congestion
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
This was (by intention) a fairly standard task. Though, it should be mentioned that graph problems always are a bit trickier than one might at first think because of the need to handle specific graph encodings.
The information provided below will be expanded in the future, but for now should help in understanding what each subtask was expecting in the form of algorithms.
- Subtask 1: Quadratic works. Because of the highly regular (linear) structure of the network graph, it is easy to try each city as the location for the arena, calculate the worst congestions and pick out the location where this worst congestion is minimal.
- Subtask 2: Requires linear algorithm, but because there are only two leaves and the graph representation is highly regular, it is easy to see that one sweep over the cities along the roads suffices to determine the optimum location.
- Subtask 3: Quadratic works, but now the general graph must be handled. Again, as in Subtask 1, every city can be tried as the arena location, the worst congestion can then be calculated, and the best location can be found.
- Subtask 4: This is the full problem. A linear traversal of the graph, accumulating congestion information appropriately, enables one to determine the optimal location of the arena in linear time.
Comments