Editorial for COCI '10 Contest 3 #1 Tablica
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.
Submitting an official solution before solving the problem yourself is a bannable offence.
There are only four different rotations of the given matrix so computing the optimal solution is straightforward - it is necessary to find the maximum of values for all rotations and keep track of the ordinal number of the rotation so we can output it. Keep in mind that if there are several rotations which give the same maximum solution, the smallest number should be output.
If this is the matrix given in the problem statement:
By rotating once, twice, and three times we get:
These four matrices generate the following values: , , , .
One trick to notice is that by multiplying each of these numbers by , we simplify double comparisons to integer comparisons.
Comments