Editorial for COCI '14 Contest 6 #5 Neo
Submitting an official solution before solving the problem yourself is a bannable offence.
It is crucial to see that the following statement holds: Matrix is extremely cool if and only if every single one of its submatrices of dimensions is cool.
Accordingly, we can construct a new matrix where the element located at is set to if . Solving this task now comes down to searching for a maximum area rectangle in matrix that consists of only s. We believe that this problem is quite familiar to the contestants, so we will not go into further analysis. Depending on the implementation complexity, it was possible to score , or of total points for time complexities , , , respectively.
We will prove the aforementioned statement using mathematical induction. First, let's write down the definition of a cool matrix as .
We prove the weaker statement: Matrix of dimensions is extremely cool if every single one of its submatrices of dimensions is cool.
We conduct the induction on .
Base: , it holds because every cool matrix is extremely cool.
Step: We assume that there is an such that the statement holds. Let's notice what happens then with a matrix of dimensions .
Since every submatrix is cool if it holds , while from the step presumption we know that for each . If we sum these inequalities, we get for each .
We conclude that if the statement holds for a matrix of dimensions , then it must hold for a matrix of dimensions . In other words, by using the principle of mathematical induction, we have proved that the statement holds for every .
Analogously, we can conduct this proof on rows in a way that we fixate two columns and conduct the induction on rows. The formal continuation of the proof is left as an exercise to the reader.
Comments