题目描述
Problem Description
A matrix $A$ is considered a "YF matrix" if and only if it satisfies:
- $r, s > 1$
- $A_{1,1} + A_{r,s} \leq A_{1,s} + A_{r,1}$
where $r$ and $s$ are the number of rows and columns of matrix $A$, respectively.
Furthermore, if every submatrix of size at least $2 \times 2$ within a matrix is a "YF matrix", we call this matrix a "Sept matrix".
Given a matrix $A$, you need to find the number of elements in the largest submatrix of $A$ that is a "Sept matrix".
Input Format
The first line contains two integers $R$ and $S$, representing the number of rows and columns of matrix $A$, respectively.
The following $R$ lines each contain $S$ integers, describing the matrix $A$.
Output Format
Output a single line containing the number of elements in the largest submatrix of $A$ that is a "Sept matrix".
If no such submatrix exists, output $0$.
Sample Input and Output
Input Sample #1
3 3
1 4 10
5 2 6
11 1 3
Output Sample #1
9
Input Sample #2
3 3
1 3 1
2 1 2
1 1 1
Output Sample #2
4
Input Sample #3
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
Output Sample #3
15
Notes
Sample 3 Explanation
The largest "Sept matrix" submatrix has its top-left and bottom-right coordinates at $(3,2)$ and $(5,6)$, respectively.
Data Size and Constraints
- For $60\%$ of the data, $R, S \leq 350$.
- For $100\%$ of the data, $2 \leq R, S \leq 10^3$, and $A_{i,j} \in [-10^6, 10^6]$.
Note
This problem is adapted from the COCI 2014-2015 Contest #6 Task E NEO.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分