#C12113. Maximum Rectangle in a Binary Matrix

    ID: 41505 Type: Default 1000ms 256MiB

Maximum Rectangle in a Binary Matrix

Maximum Rectangle in a Binary Matrix

Given a binary matrix represented by a list of strings, your task is to find the area of the largest rectangle composed entirely of '1's. The area (A) of a rectangle is defined by the formula (A = width \times height).

For example, consider the following matrix:

10100
10111
11111
10010

The largest rectangle containing only '1's has an area of 6.

inputFormat

The first line contains an integer (R) representing the number of rows in the matrix. If (R > 0), each of the following (R) lines contains a binary string (consisting only of the characters '0' and '1') of equal length.

outputFormat

Output a single integer which is the area of the largest rectangle formed by adjacent '1's in the matrix.## sample

4
10100
10111
11111
10010
6