-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP10074.cpp
54 lines (48 loc) · 958 Bytes
/
P10074.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <stdio.h>
/*
Process lines while maintaining length of up-rays:
Example:
Maze Up-rays Max areas
XX-XX 00100 00100
XX--X 00210 00220
----X 11320 12340
XX-XX 00400 00400
=> O(n^3)
*/
int main () {
//bool mtx[100*100];
int N, M, e, upRays[100];
while(true) {
std::cin >> N >> M;
if(N == 0 && M == 0)
return 0;
for(int x = 0; x < M; ++x) {
upRays[x] = 0;
}
int area = 0;
for(int y = 0; y < N; ++y) {
for(int x = 0; x < M; ++x) {
std::cin >> e;
if(e == 1)
upRays[x] = 0;
else
++upRays[x];
}
for(int x = 0; x < M; ++x) {
int upRay = upRays[x];
if(upRay > 0) {
int xMin = x, xMax = x;
while(xMin > 0 && upRays[xMin-1]>=upRay)
--xMin;
while(xMax < M-1 && upRays[xMax+1]>=upRay)
++xMax;
int newArea = upRay*(xMax-xMin+1);
if(area < newArea)
area = newArea;
}
}
}
std::cout << area << std::endl;
}
}