#K10686. Largest Rectangle of Vacant Cells

    ID: 23302 Type: Default 1000ms 256MiB

Largest Rectangle of Vacant Cells

Largest Rectangle of Vacant Cells

You are given a 2D grid of integers with n rows and m columns. Each cell contains either 0 or 1. A 0 represents a vacant cell, and a 1 represents an occupied cell. Your task is to determine the area of the largest rectangle consisting entirely of vacant cells (i.e. cells with value 0).

Formally, if the area of a rectangle is denoted by \(\text{Area} = \text{width} \times \text{height}\), you are to compute the maximum \(\text{Area}\) over all rectangular sub-grids which contain only 0's.

Example: For the grid below:

1 0 1 0
0 0 1 0
0 0 0 0
1 0 1 1

The largest rectangle of 0's has area 4.

inputFormat

The first line contains two integers n and m representing the number of rows and columns respectively. Each of the following n lines contains m integers (each 0 or 1) separated by spaces, representing the grid.

It is guaranteed that n and m are positive integers.

outputFormat

Output a single integer representing the area of the largest rectangle composed solely of 0's.

## sample
4 4
1 0 1 0
0 0 1 0
0 0 0 0
1 0 1 1
4