To a matrix, which is still the maximal sub-matrix for satisfying the condition
But the problem is that any two columns can be exchanged, which is a simplification of the topic
The h array is then sorted directly and then the maximum value (COL-J) *h[j] is found (j here is starting from 0)
Because sorting affects the solution of the next row in the H array, the elements in the H array are copied to the temp array and sorted
1 //#define LOCAL2#include <iostream>3#include <cstdio>4#include <cstring>5#include <algorithm>6 using namespacestd;7 8 Const intMAXN =1010;9 CharMAP[MAXN][MAXN];Ten intH[MAXN], TEMP[MAXN]; One A intMainvoid) - { - #ifdef LOCAL theFreopen ("2830in.txt","R", stdin); - #endif - - intRow, col; + while(SCANF ("%d%d", &row, &col) = =2) - { + intI, J; A for(i =0; i < row; ++i) atscanf"%s", Map[i]); -memset (H,0,sizeof(h)); - intAns =0; - for(i =0; i < row; ++i) - { - for(j =0; J < Col; ++j) in { - if(Map[i][j] = ='1') to++H[j]; + Else -H[J] =0; the } *memcpy (temp, H,sizeof(h)); $Sort (temp, temp +col);Panax Notoginseng for(j =0; J < Col; ++j) -ans = max (ans, (col-j) *temp[j]); the } +printf"%d\n", ans); A } the return 0; +}code June