Editorial for COCI '14 Contest 6 #3 Meteor


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.

We need to calculate the shift of the meteor in relation to its initial position or, in other words, the number of fields it fell towards the ground. If we think about it, we conclude that this shift is equal to the minimal vertical distance from a part of the meteor to a part of the ground, minus one. This distance is calculated in a way that we find the lowest part of the meteor and the highest part of the ground for each column; their vertical difference is a candidate for the minimal distance.

After we have calculated the shift, every part of the meteor needs to be shifted. It is most easily done by using a new photograph (matrix of characters) in which we first copy all parts of the ground, fill the rest out with dots, and then add the meteor parts in the calculated positions.


Comments

There are no comments at the moment.