1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: 10074 - Take the Land
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=12&problem=1015&mosmsg=Submission+received+with+ID+8484757
*
* @author Manuel Hager
* @version 1.0, 12/28/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.016
*/

#include <iostream>
#define QUANTITY 100

using namespace std;

unsigned int row, col;
int c, r;
bool field[QUANTITY][QUANTITY];
int tmp;
int result;

int calculateSquare(int x, int y) {
int x_var = 1, y_var = 1;
for(; x + x_var < col && !field[y][x + x_var]; x_var++) {}
for(; y + y_var < row && !field[y + y_var][x]; y_var++) {}

if(x_var * y_var > result) {
int sum = x_var > y_var? x_var : y_var;

for(int x1 = 1; x1 < x_var; x1++) {
int y1 = 1;
for(; y1 < y_var && !field[y + y1][x + x1]; y1++) {}
y_var = y1;
tmp = (x1 + 1) * y1;
if(tmp > sum) { sum = tmp; }
}
return sum;
}
return 1;
}

int process() {
result = 0;

for(r = 0; r < row; r++) {
for(c = 0; c < col; c++) {
if(!field[r][c]) {
int curr = calculateSquare(c, r);
if(curr > result) {
result = curr;
}
}
}
}
return result;
}

int main(int argc, int* argv[]) {
do {
cin >> row >> col;
if(row == 0 && col == 0)
break;

for(r = 0; r < row; r++)
for(c = 0; c < col; c++)
cin >> tmp, field[r][c] = tmp;

cout << process() << endl;
}while(true);

return 0;
}



2.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10074 - Take the Land
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=12&problem=1015&mosmsg=Submission+received+with+ID+8027444
*
* @author Evgeni Pavlidis
* @version 1.0, 06/08/2010
*
* Method : Kadane - Max substring
* Status : Accepted
* Runtime: 0.232
*/

import java.io.*;
import java.util.*;

class Main {

private static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

private static int nextInt() throws Exception
{
st.nextToken();
return (int)st.nval;
}

public static void main(String...args) throws Exception
{
int[][] rowSum = new int[102][102];
int rows, columns, sum = 0, max, t;

while(true)
{
rows = nextInt();
columns = nextInt();

if(rows == 0 && columns == 0)
break;


// accumulate row sums
for(int r = 0; r < rows; r++, sum = 0)
for(int c = 0; c < columns; c++)
rowSum[r][c+1] = sum = sum + ((t = nextInt()) == 1? -(100*100): 1);


// find max substring (submatrix)
max = 0;
for(int c1 = 1; c1 <= columns; c1++)
for(int c2 = c1; c2 <= columns; c2++, sum = 0)
for(int r = 0; r < rows; r++)
{
sum += rowSum[r][c2] - rowSum[r][c1-1];

if(sum < 0)
sum = 0;

if(sum > max)
max = sum;
}

System.out.println(max);
}
}
}