Rectangular Dry Land
InterviewTime limit7sMemory limit1024 MB
Given a binary grid of wet and dry cells, find the area of the largest rectangle made only of dry cells.
- Level
Medium5 of 10
- Topics
- Matrix, Stack, Dynamic programming
- Solved
- No attempts yet
Problem
Florida has many wetlands, so finding space to build houses is difficult. The problem is worse when people insist that their houses be rectangular.
The land is a two-dimensional rectangular grid, and each cell is either wet or dry. Find the largest rectangular dry area, that is, the largest house you can build by area. The house must be rectangular, so the dry cells you use must form a rectangle, and that rectangle cannot contain any wet cells.
Input
The first line contains two integers () and (), the number of rows and columns of the land.
Each of the next lines describes one row. Each line has characters, starting from column 1. Each character is either 1 (wetland) or 0 (dryland).
Output
Print the area of the largest rectangular dryland.