- #include <iostream>
- using namespace std;
-
- int tableau[1024][1024];
-
- int bigRect(int l, int c)
- {
- int x = 0, y, i, j;
- i = c + 1; j = 1; l++;
- do{
- i--;
- if(tableau[i][j]==1)x = 0;
- else x++;
- tableau[i][j] = x;
- if(i == 1){x = 0; j++; i = c + 1;}
- }while(j <= l);
- l--;
- //Il ne me reste que 4 secondes !
- int q, s, d, f, res;
- int max = tableau[1][1];
- for(q = 1; q < l; q++)
- {
- for(s = 1; s < c; s++)
- {
- if(q > 1 && tableau[s][q-1] >= tableau[s][q])
- {
- if(tableau[s][q]+s-1 == c)s = c - 1;
- else s += tableau[s][q];
- goto suite;
- }
- if(tableau[s][q] > 1)
- {
- for(d = tableau[s][q]; d > 1; d--)
- {
- for(f = q; f <= l; f++)
- {
- if(tableau[s][f] >= d){if((res=d*(f-q+1)) > max)max = res;}
- else if(tableau[s][f] < 2 ||(f == l && tableau[s][q]+s-1 == c))goto suite;
- else break;
- }
- }
- }
- suite:;
- }
- }
- return max;
- }
-
- int main()
- {
- int l, c, L, C;
- cin >> l >> c;
- for(L = 1; L <= l; L++)
- for(C = 1; C <= c; C++)
- cin >> tableau[C][L];
- cout << bigRect(l, c);
- return 0;
- }
#include <iostream>
using namespace std;
int tableau[1024][1024];
int bigRect(int l, int c)
{
int x = 0, y, i, j;
i = c + 1; j = 1; l++;
do{
i--;
if(tableau[i][j]==1)x = 0;
else x++;
tableau[i][j] = x;
if(i == 1){x = 0; j++; i = c + 1;}
}while(j <= l);
l--;
//Il ne me reste que 4 secondes !
int q, s, d, f, res;
int max = tableau[1][1];
for(q = 1; q < l; q++)
{
for(s = 1; s < c; s++)
{
if(q > 1 && tableau[s][q-1] >= tableau[s][q])
{
if(tableau[s][q]+s-1 == c)s = c - 1;
else s += tableau[s][q];
goto suite;
}
if(tableau[s][q] > 1)
{
for(d = tableau[s][q]; d > 1; d--)
{
for(f = q; f <= l; f++)
{
if(tableau[s][f] >= d){if((res=d*(f-q+1)) > max)max = res;}
else if(tableau[s][f] < 2 ||(f == l && tableau[s][q]+s-1 == c))goto suite;
else break;
}
}
}
suite:;
}
}
return max;
}
int main()
{
int l, c, L, C;
cin >> l >> c;
for(L = 1; L <= l; L++)
for(C = 1; C <= c; C++)
cin >> tableau[C][L];
cout << bigRect(l, c);
return 0;
}