#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define N 2505
int a[N][N];
int up[N][N], le[N][N];
int h[2505], w[2505];
vector<pair<int, int> > v;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
memset(h, 0x3f, sizeof h);
memset(w, 0x3f, sizeof w);
int n, m;
cin>>n>>m;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
char c;
cin>>c;
a[i][j] = c - '0';
}
}
int mx= 2500;
for(int i = 1; i <= m; ++i){
for(int j = 1; j <= n; ++j){
if(a[j][i] == 0) up[j][i] = 0;
else up[j][i] = up[j - 1][i] + 1;
if(a[j + 1][i] == 0 && a[j][i] == 1)mx = min(mx, up[j][i]);
}
}
v.push_back({0, 0});
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m + 1; ++j){
int t = 0;
while(v.back().ff > up[i][j]){
v.back().ss += t;
h[v.back().ff] = min(h[v.back().ff], v.back().ss);
t = v.back().ss;
v.pop_back();
if(v.back().ff > up[i][j]){
h[v.back().ff + 1] = min(h[v.back().ff + 1], t);
}
}
if(v.back().ff == up[i][j]){
v.back().ss += 1 + t;
} else {
v.push_back({up[i][j], 1 + t});
}
if(t)h[v.back().ff + 1] = min(h[v.back().ff + 1], t);
}
}
int ans = 0;
for(int i = 1; i <= mx; ++i){
h[i] = min(h[i - 1], h[i]);
ans = max(ans, h[i] * i);
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
17 ms |
20472 KB |
Output is correct |
4 |
Correct |
17 ms |
20472 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Correct |
2 ms |
504 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
2 ms |
508 KB |
Output is correct |
17 |
Incorrect |
2 ms |
888 KB |
Output isn't correct |
18 |
Correct |
3 ms |
1016 KB |
Output is correct |
19 |
Correct |
3 ms |
1272 KB |
Output is correct |
20 |
Incorrect |
3 ms |
1272 KB |
Output isn't correct |
21 |
Correct |
2 ms |
888 KB |
Output is correct |
22 |
Correct |
3 ms |
1016 KB |
Output is correct |
23 |
Incorrect |
3 ms |
1272 KB |
Output isn't correct |
24 |
Incorrect |
3 ms |
1016 KB |
Output isn't correct |
25 |
Incorrect |
3 ms |
1272 KB |
Output isn't correct |
26 |
Incorrect |
3 ms |
1272 KB |
Output isn't correct |
27 |
Correct |
7 ms |
3448 KB |
Output is correct |
28 |
Correct |
7 ms |
3704 KB |
Output is correct |
29 |
Incorrect |
9 ms |
4600 KB |
Output isn't correct |
30 |
Incorrect |
10 ms |
5448 KB |
Output isn't correct |
31 |
Incorrect |
8 ms |
4344 KB |
Output isn't correct |
32 |
Incorrect |
9 ms |
4984 KB |
Output isn't correct |
33 |
Incorrect |
10 ms |
5752 KB |
Output isn't correct |
34 |
Correct |
6 ms |
3960 KB |
Output is correct |
35 |
Incorrect |
11 ms |
5752 KB |
Output isn't correct |
36 |
Incorrect |
11 ms |
5752 KB |
Output isn't correct |
37 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
38 |
Correct |
332 ms |
51856 KB |
Output is correct |
39 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
40 |
Incorrect |
35 ms |
14200 KB |
Output isn't correct |
41 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
42 |
Incorrect |
3 ms |
1272 KB |
Output isn't correct |
43 |
Correct |
355 ms |
52000 KB |
Output is correct |
44 |
Incorrect |
11 ms |
5752 KB |
Output isn't correct |
45 |
Incorrect |
349 ms |
51884 KB |
Output isn't correct |
46 |
Correct |
336 ms |
51832 KB |
Output is correct |
47 |
Incorrect |
351 ms |
51960 KB |
Output isn't correct |
48 |
Incorrect |
328 ms |
51892 KB |
Output isn't correct |
49 |
Correct |
338 ms |
51960 KB |
Output is correct |
50 |
Incorrect |
337 ms |
51832 KB |
Output isn't correct |
51 |
Incorrect |
331 ms |
51960 KB |
Output isn't correct |
52 |
Incorrect |
356 ms |
51960 KB |
Output isn't correct |
53 |
Incorrect |
334 ms |
51832 KB |
Output isn't correct |
54 |
Correct |
334 ms |
52016 KB |
Output is correct |
55 |
Correct |
327 ms |
51976 KB |
Output is correct |
56 |
Correct |
338 ms |
51916 KB |
Output is correct |
57 |
Correct |
331 ms |
51832 KB |
Output is correct |
58 |
Correct |
329 ms |
51804 KB |
Output is correct |
59 |
Correct |
338 ms |
51844 KB |
Output is correct |
60 |
Correct |
333 ms |
51916 KB |
Output is correct |
61 |
Correct |
337 ms |
51836 KB |
Output is correct |
62 |
Correct |
330 ms |
51844 KB |
Output is correct |
63 |
Correct |
335 ms |
51832 KB |
Output is correct |
64 |
Correct |
325 ms |
51832 KB |
Output is correct |
65 |
Incorrect |
350 ms |
51860 KB |
Output isn't correct |
66 |
Incorrect |
337 ms |
51792 KB |
Output isn't correct |
67 |
Incorrect |
334 ms |
51876 KB |
Output isn't correct |
68 |
Incorrect |
338 ms |
51936 KB |
Output isn't correct |
69 |
Correct |
330 ms |
51960 KB |
Output is correct |
70 |
Incorrect |
212 ms |
40824 KB |
Output isn't correct |
71 |
Incorrect |
327 ms |
51996 KB |
Output isn't correct |
72 |
Incorrect |
342 ms |
51832 KB |
Output isn't correct |
73 |
Incorrect |
332 ms |
51960 KB |
Output isn't correct |
74 |
Incorrect |
331 ms |
51960 KB |
Output isn't correct |
75 |
Incorrect |
336 ms |
51832 KB |
Output isn't correct |
76 |
Incorrect |
334 ms |
51512 KB |
Output isn't correct |
77 |
Incorrect |
332 ms |
51192 KB |
Output isn't correct |
78 |
Incorrect |
332 ms |
50460 KB |
Output isn't correct |
79 |
Incorrect |
327 ms |
50472 KB |
Output isn't correct |
80 |
Incorrect |
330 ms |
50456 KB |
Output isn't correct |
81 |
Incorrect |
326 ms |
50936 KB |
Output isn't correct |
82 |
Incorrect |
343 ms |
50736 KB |
Output isn't correct |
83 |
Incorrect |
325 ms |
51320 KB |
Output isn't correct |
84 |
Incorrect |
324 ms |
51316 KB |
Output isn't correct |
85 |
Incorrect |
333 ms |
50296 KB |
Output isn't correct |
86 |
Correct |
328 ms |
50936 KB |
Output is correct |
87 |
Correct |
324 ms |
50788 KB |
Output is correct |
88 |
Incorrect |
326 ms |
51144 KB |
Output isn't correct |
89 |
Incorrect |
323 ms |
50552 KB |
Output isn't correct |
90 |
Incorrect |
205 ms |
40568 KB |
Output isn't correct |
91 |
Incorrect |
330 ms |
50628 KB |
Output isn't correct |
92 |
Incorrect |
340 ms |
50680 KB |
Output isn't correct |
93 |
Incorrect |
331 ms |
50552 KB |
Output isn't correct |
94 |
Incorrect |
323 ms |
50056 KB |
Output isn't correct |
95 |
Incorrect |
335 ms |
50168 KB |
Output isn't correct |
96 |
Incorrect |
324 ms |
50468 KB |
Output isn't correct |
97 |
Incorrect |
405 ms |
50436 KB |
Output isn't correct |
98 |
Incorrect |
333 ms |
50424 KB |
Output isn't correct |
99 |
Incorrect |
320 ms |
50240 KB |
Output isn't correct |
100 |
Incorrect |
322 ms |
50296 KB |
Output isn't correct |