Polish version    English version  
  History of OI -> IX OI 2001/2002


 News
 About Olympic
 History of OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
X OI 2002/2003
IX OI 2001/2002
Schedule
Problems
Stage III - results
Stage II - results
Stage I - results
Stage II
Rules
For contestants
Helpful resources
Stats
VIII OI 2000/2001
VII OI 1999/2000
VI OI 1998/1999
V OI 1997/1998
IV OI 1996/1997
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
IX Olympiad in Informatics

Task: dzi
Author: Jakub Pawlewicz
Parcel

II stage contest  

We are given a square-shaped field. The field has a side of length n and it is divided into n2 squares of side 1. Each square is either arable or waste land. We delimit a parcel in the field. The parcel ought to be a rectangle and to consist of only arable squares. The area of the parcel is equal to the area of the corresponding rectangle. We seek for a parcel of the largest area.

Task

Write a program which:
  • reads from the text file dzi.in the description of the field,
  • computes the area of the largest parcel (there may be more than one such a parcel),
  • writes to the text file dzi.out the computed area.

Input

In the first line of the text file dzi.in there is one integer n, 1 <= n <= 2000. In the successive n lines there are descriptions of squares that compose successive rows of the field. Each of those lines comprises n numbers 0 or 1, separated by single spaces. The numbers describe successive squares in the row: 0 denotes an arable square and 1 denotes a waste square.

Output

Your program should write one integer in the first and only line of the text file dzi.out. The number should be the area of the largest parcel. If all the squares are waste and there is no parcel, your program should give the answer 0.

Example

For the following input file dzi.in:
5
0 1 0 1 0
0 0 0 0 0
0 0 0 0 1
1 0 0 0 0
0 1 0 0 0
the correct answer is in the following output file dzi.out:
9



Print friendly version