Editorial for IOI '00 P2 - Car Parking
Submitting an official solution before solving the problem yourself is a bannable offence.
The final state of the parking center can easily be determined by sorting the input list of car types. This can be done in linear time (). and methods may be too slow for larger .
A greedy approach to construct successive rounds will work, since in each round it can be guaranteed that at least cars are put into their final position. Hence, the number of rounds needed by this greedy algorithm is , where is the number of displaced cars in the initial state for the input. In general, finding the minimum number of rounds is NP-complete. Even reducing the number of rounds for the greedy algorithm by just one round is, in general, as hard as finding the minimum (compare to bin packing: you need to find cycles that add up in length to , for otherwise one worker is not doing useful work).
The greedy algorithm can be implemented in space and time. However, a more naive implementation may use space and time. The test data has been designed to distinguish linear solutions from less efficient ones.
Comments