Editorial for IOI '00 P4 - Walls


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.

A straightforward solution can be based on the dual graph of the planar graph representing the map of towns and connecting walls. The dual graph is obtained by viewing the areas as nodes that are connected when they share a wall (this can be a multigraph).

Traversing an edge in the dual graph corresponds to crossing a wall, hence minimizing wall crossings corresponds to selecting shortest paths in the dual graph.

A brute force approach tries each area (factor M) as a meeting area and determines the best routes for each member (factor L) by trying each starting area (factor \le N). Applying Warshall's all-pairs shortest path algorithm on the dual graph provides all the information needed. This yields an \mathcal O(N^3+MLN) algorithm to solve the problem. The time limit is chosen such that this solution is acceptable, even though the complexity can be reduced by selecting a different algorithm for determining all relevant distances.


Comments

There are no comments at the moment.