#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2500;
int mat[MAX_N + 2][MAX_N + 2], up[MAX_N + 2][MAX_N + 2], down[MAX_N + 2][MAX_N + 2], hup[MAX_N + 2], hdown[MAX_N + 2], maxHeight[MAX_N + 2];
int main() {
int n, m;
cin >> n >> m;
for ( int l = 1; l <= n; l++ ) {
for ( int c = 1; c <= m; c++ ) {
char ch;
cin >> ch;
mat[l][c] = ch - '0';
}
}
for ( int l = 1; l <= n; l++ ) {
for ( int c = 1; c <= m; c++ )
up[l][c] = (mat[l][c] ? up[l - 1][c] + 1 : 0);
}
for ( int l = n; l >= 1; l-- ) {
for ( int c = 1; c <= m; c++ )
down[l][c] = (mat[l][c] ? down[l + 1][c] + 1 : 0);
}
for ( int i = 0; i <= m; i++ )
maxHeight[i] = n;
for ( int l = 1; l <= n; l++ ) {
int cons1 = 0, hup = n, hdown = n;
for ( int c = 1; c <= m; c++ ) {
if ( mat[l][c] ) {
cons1++;
hup = min( hup, up[l][c] );
hdown = min( hdown, down[l][c] );
maxHeight[cons1] = min( maxHeight[cons1], hup + hdown - 1 );
} else
cons1 = 0, hup = n, hdown = n;
}
}
int maxArea = 0;
for ( int i = 1; i <= n; i++ ) {
maxHeight[i] = min( maxHeight[i], maxHeight[i - 1] );
maxArea = max( maxArea, maxHeight[i] * i );
}
cout << maxArea;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Correct |
0 ms |
608 KB |
Output is correct |
3 |
Correct |
11 ms |
30556 KB |
Output is correct |
4 |
Correct |
10 ms |
30556 KB |
Output is correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
444 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
18 |
Incorrect |
1 ms |
1128 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
1628 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
1628 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
1372 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
1628 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
1372 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
1628 KB |
Output isn't correct |
26 |
Incorrect |
1 ms |
1628 KB |
Output isn't correct |
27 |
Incorrect |
4 ms |
4956 KB |
Output isn't correct |
28 |
Incorrect |
5 ms |
5212 KB |
Output isn't correct |
29 |
Incorrect |
6 ms |
6492 KB |
Output isn't correct |
30 |
Incorrect |
7 ms |
7844 KB |
Output isn't correct |
31 |
Correct |
6 ms |
6236 KB |
Output is correct |
32 |
Incorrect |
8 ms |
7276 KB |
Output isn't correct |
33 |
Incorrect |
10 ms |
8284 KB |
Output isn't correct |
34 |
Incorrect |
4 ms |
5724 KB |
Output isn't correct |
35 |
Incorrect |
9 ms |
8348 KB |
Output isn't correct |
36 |
Incorrect |
8 ms |
8280 KB |
Output isn't correct |
37 |
Incorrect |
0 ms |
608 KB |
Output isn't correct |
38 |
Correct |
209 ms |
79860 KB |
Output is correct |
39 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
40 |
Incorrect |
29 ms |
20564 KB |
Output isn't correct |
41 |
Correct |
1 ms |
860 KB |
Output is correct |
42 |
Correct |
1 ms |
1628 KB |
Output is correct |
43 |
Incorrect |
197 ms |
79968 KB |
Output isn't correct |
44 |
Correct |
9 ms |
8284 KB |
Output is correct |
45 |
Incorrect |
211 ms |
79900 KB |
Output isn't correct |
46 |
Incorrect |
214 ms |
79852 KB |
Output isn't correct |
47 |
Incorrect |
188 ms |
79960 KB |
Output isn't correct |
48 |
Correct |
210 ms |
79756 KB |
Output is correct |
49 |
Incorrect |
213 ms |
79832 KB |
Output isn't correct |
50 |
Correct |
199 ms |
79784 KB |
Output is correct |
51 |
Correct |
190 ms |
79824 KB |
Output is correct |
52 |
Correct |
206 ms |
79896 KB |
Output is correct |
53 |
Correct |
197 ms |
79952 KB |
Output is correct |
54 |
Correct |
192 ms |
79964 KB |
Output is correct |
55 |
Incorrect |
212 ms |
79956 KB |
Output isn't correct |
56 |
Incorrect |
208 ms |
79792 KB |
Output isn't correct |
57 |
Incorrect |
222 ms |
79952 KB |
Output isn't correct |
58 |
Correct |
204 ms |
79956 KB |
Output is correct |
59 |
Correct |
202 ms |
79888 KB |
Output is correct |
60 |
Incorrect |
229 ms |
79908 KB |
Output isn't correct |
61 |
Incorrect |
190 ms |
79952 KB |
Output isn't correct |
62 |
Incorrect |
196 ms |
79848 KB |
Output isn't correct |
63 |
Incorrect |
201 ms |
79804 KB |
Output isn't correct |
64 |
Incorrect |
187 ms |
79956 KB |
Output isn't correct |
65 |
Incorrect |
207 ms |
79952 KB |
Output isn't correct |
66 |
Correct |
211 ms |
79860 KB |
Output is correct |
67 |
Correct |
198 ms |
79952 KB |
Output is correct |
68 |
Correct |
199 ms |
79956 KB |
Output is correct |
69 |
Correct |
205 ms |
79956 KB |
Output is correct |
70 |
Incorrect |
127 ms |
63060 KB |
Output isn't correct |
71 |
Incorrect |
225 ms |
79952 KB |
Output isn't correct |
72 |
Incorrect |
189 ms |
79952 KB |
Output isn't correct |
73 |
Correct |
188 ms |
79876 KB |
Output is correct |
74 |
Incorrect |
195 ms |
79876 KB |
Output isn't correct |
75 |
Incorrect |
195 ms |
79952 KB |
Output isn't correct |
76 |
Incorrect |
208 ms |
79956 KB |
Output isn't correct |
77 |
Incorrect |
200 ms |
79852 KB |
Output isn't correct |
78 |
Incorrect |
200 ms |
79856 KB |
Output isn't correct |
79 |
Incorrect |
197 ms |
79780 KB |
Output isn't correct |
80 |
Incorrect |
187 ms |
79952 KB |
Output isn't correct |
81 |
Incorrect |
195 ms |
79956 KB |
Output isn't correct |
82 |
Incorrect |
196 ms |
79952 KB |
Output isn't correct |
83 |
Incorrect |
188 ms |
79956 KB |
Output isn't correct |
84 |
Incorrect |
188 ms |
79952 KB |
Output isn't correct |
85 |
Incorrect |
210 ms |
79872 KB |
Output isn't correct |
86 |
Incorrect |
211 ms |
79848 KB |
Output isn't correct |
87 |
Incorrect |
232 ms |
79956 KB |
Output isn't correct |
88 |
Correct |
228 ms |
79844 KB |
Output is correct |
89 |
Correct |
185 ms |
79916 KB |
Output is correct |
90 |
Incorrect |
132 ms |
62896 KB |
Output isn't correct |
91 |
Incorrect |
183 ms |
79956 KB |
Output isn't correct |
92 |
Incorrect |
183 ms |
79936 KB |
Output isn't correct |
93 |
Incorrect |
203 ms |
79952 KB |
Output isn't correct |
94 |
Correct |
215 ms |
79960 KB |
Output is correct |
95 |
Incorrect |
201 ms |
79872 KB |
Output isn't correct |
96 |
Correct |
209 ms |
79956 KB |
Output is correct |
97 |
Incorrect |
244 ms |
79952 KB |
Output isn't correct |
98 |
Incorrect |
212 ms |
79868 KB |
Output isn't correct |
99 |
Incorrect |
209 ms |
79760 KB |
Output isn't correct |
100 |
Incorrect |
226 ms |
79796 KB |
Output isn't correct |