NEO
Time limit1sMemory limit256 MB
Find the largest submatrix with at least two rows and columns in which every submatrix meets the corner-sum inequality.
Problem
Write for the element of matrix in row and column . A matrix with rows and columns is cool if both of these hold.
- and
A matrix with at least two rows and at least two columns is extremely cool if every submatrix of it that has at least two rows and at least two columns is cool.
A submatrix is the rectangular region where a range of consecutive rows meets a range of consecutive columns.
Find an extremely cool submatrix of the given matrix and report the largest number of elements such a submatrix can have.
Input
The first line contains two integers and , the dimensions of the matrix ().
Each of the next lines contains integers, one row of the matrix. Every element is an integer between and .
Output
Print one line with the largest number of elements an extremely cool submatrix of the given matrix has. If the matrix has no extremely cool submatrix, print 0.