#C6529. Maximal Rectangle in a Binary Grid

    ID: 50299 Type: Default 1000ms 256MiB

Maximal Rectangle in a Binary Grid

Maximal Rectangle in a Binary Grid

You are given a 2D binary grid consisting of characters '0' and '1'. Your task is to compute the area of the largest rectangle containing only '1's.

Consider a grid with r rows and c columns. The problem is to choose a subrectangle such that every cell in the rectangle is '1' and the area (number of cells) is maximized.

The area of a rectangle is given by \(\text{area} = \text{height} \times \text{width}\).

Note: The input is provided via standard input and the output must be printed to standard output.

inputFormat

The first line contains two integers \(r\) and \(c\) representing the number of rows and columns of the grid.

Each of the following \(r\) lines contains exactly \(c\) tokens, each being either 0 or 1, separated by spaces.

You may assume that \(0 \le r, c \le 1000\).

outputFormat

Print a single integer representing the area of the largest rectangle which consists only of 1's.

## sample
4 5
1 0 1 0 0
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
6