luogu#P7958. [COCI 2014/2015 #6] NEO
[COCI 2014/2015 #6] NEO
Problem Description
A matrix is a "YF matrix" if and only if it satisfies:
- .
- .
Here, and are the numbers of rows and columns of matrix , respectively.
Also, if every submatrix of a matrix with size at least is a "YF matrix", then we call this matrix a "Sept matrix".
Given a matrix , you need to find the number of elements in the largest submatrix of that is a "Sept matrix".
Input Format
The first line contains two integers , which are the numbers of rows and columns of , respectively.
The next lines each contain integers, describing matrix .
Output Format
Output one line: the number of elements in the largest submatrix of that is a "Sept matrix".
If no such submatrix exists, output .
3 3
1 4 10
5 2 6
11 1 3
9
3 3
1 3 1
2 1 2
1 1 1
4
5 6
1 1 4 0 3 3
4 4 9 7 11 13
-3 -1 4 2 8 11
1 5 9 5 9 10
4 8 10 5 8 8
15
Hint
Explanation for Sample 3
The top-left and bottom-right coordinates of the largest submatrix that is a "Sept matrix" are and , respectively.
Constraints
- For of the testdata, .
- For of the testdata, , and .
Notes
According to the original problem settings, the full score is 140 points.
Translated from COCI 2014-2015 Contest #6 Task E NEO.
Translated by ChatGPT 5