>>107836050
Then solve it on paper first.
>>107836105
For each row calculate starts and ends of each sequence of 1s (range).
Then for each such range in each row:
>1. save depth = 1
>2. calculate range.width * depth
, if it's the largest so far save it (as max)
>3. if there is no more rows left, break
>4. look at row below and binary search for all ranges that overlap with this one
>5. for each range(subrange
) that overlaps with the current range:
>5.1. find the intersection max(subrange.start, range.start) .. min(subrange.end, range.end)
and recursively go to 2. using it as your new range