Editorial for IOI '97 P4 - Map Labelling


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.
  • The labels are sorted in order of smallest first.
  • Each label in the above order is inserted one after the other if it can be in one of the 4 positions possible.
  • Once all the labels that can be inserted this way have been, then the labels that are already in get shifted around if they can be. This might open gaps into which uninserted labels are placed.

There are two versions of maps. This is because many contestants used the sample solution in their programming directory to determine direction, and this sample was wrong. One version corresponds to the problem description and the other to the sample solution.


Comments

There are no comments at the moment.