Editorial for IOI '97 P3 - The Toxic iShongololo


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 3D array is created to represent the "fruit" which the iShongololo is going to be eating. This array is then initialised to all being edible.

The iShongololo starts eating at the block 1, 1, 1 and then moves to the first block eaten. It then moves in a positive lengthwise direction eating all adjacent blocks (horizontal and vertical) that don't violate the rules.

On reaching a side, it calculates whether the iShongololo can turn without violating rules and stops eating adjacent blocks. It will then turn and continue this process. When no further horizontal blocks can be eaten, the iShongololo will move downwards 4 blocks and continue this pattern, noting that it also eats as many blocks upwards and downwards and horizontally as possible, again, leaving enough uneaten block at the corners to turn.

Once there are no further edible blocks, the programme ends.

To further optimise the solutions, the solutions are run from 3 directions, alternately taking the length, width and height as the 'top' face for the iShongololo to use. The best of these is then used.


Comments

There are no comments at the moment.