/* Description: In an M * n matrix, all the elements are only 0 and 1. From this matrix, find a fully-1 sub-matrix with the largest area, the maximum is the maximum number of elements 1. Input: the input may contain multiple test examples. For each test case, the first line of input is two integers m, n (1 <= m, n <= 1000): represents the size of the matrix to be input. There are m rows in the Matrix. Each row has n integers, which are 0 or 1 respectively. The adjacent two numbers are strictly separated by a space. Output: For each test case, the number of elements in the matrix with the largest area in all 1 child matrices is displayed. Sample input: 2 20 00 04 40 0 0 00 1 1 00 1 00 0 0 0 0 sample output: 04 train of thought: each vertex, scan it up, left, the boundary derived from the right is up [I] [J] * (right [I] [J]-left [I] [J] + 1) */# include <stdio. h> const int n= 1001; int map [N] [N], up [N] [N], left [N] [N], right [N] [N]; int max (int x, int y) {If (x> Y) return X; return y;} int min (int x, int y) {If (x <Y) return X; return y;} int main () {int n, m; while (scanf ("% d", & M, & N )! = EOF) {for (INT I = 0; I <m; I ++) for (Int J = 0; j <n; j ++) scanf ("% d", & map [I] [J]); int ans = 0; For (INT I = 0; I <m; I ++) {int Lo =-1; int RO = N; For (Int J = 0; j <n; j ++) {If (Map [I] [J] = 0) {up [I] [J] = 0; left [I] [J] = 0; Lo = J ;} else {if (I = 0) {up [I] [J] = 1; left [I] [J] = lo + 1 ;} else {up [I] [J] = up [I-1] [J] + 1; left [I] [J] = max (Lo + 1, left [I-1] [J]) ;}}for (Int J = n-1; j> = 0; j --) {If (Map [I] [J] = 0) {right [I] [J] = N; RO = J;} else {if (I = 0) {right [I] [J] = ro-1;} else {right [I] [J] = min (ro-1, right [I-1] [J]);} ans = max (ANS, up [I] [J] * (right [I] [J]-left [I] [J] + 1 ));}} printf ("% d \ n", ANS);} return 0 ;}