Editorial for COCI '15 Contest 7 #2 Prozor


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 limitations from the task allow us to evaluate every possible shot. In other words, we can assume for each pixel that it is the one located in the upper left corner of the racket and then count how many flies would be affected by that shot. When done with this procedure for each pixel, we know the position of the upper left pixel of the optimal shot, and that is sufficient in order to reconstruct the image and score all points for this task. Additionally, we need to make sure that the racket is located entirely within the image and that we won't affect the flies located on the edges of the racket.

The time complexity of the aforementioned procedure is \mathcal O(R^2 S^2). Moreover, we encourage you to come up with a solution for this task given the limitation (3 \le R, S \le 1000).


Comments

There are no comments at the moment.