#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
const int maxn = 2502;
int n, m;
int a[maxn][maxn], b[maxn][maxn];
bool solve(int x, int y){
memset(b, 0, sizeof(b));
for(int i = x; i <= n; i++){
for(int j = y; j <= m; j++){
if(a[i][j] - a[i - x][j] - a[i][j - y] + a[i - x][j - y] == x * y){
b[i - x + 1][j - y + 1]++;
b[i - x + 1][j + 1]--;
b[i + 1][j - y + 1]--;
b[i + 1][j + 1]++;
}
}
}
int amt = a[n][m];
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
amt -= (b[i][j] > 0);
}
}
return amt == 0;
}
int solveh(int x){
int l = 0, r = n + 1;
while(r - l > 1){
int mid = (l + r) / 2;
if(solve(mid, x)) l = mid;
else r = mid;
}
return l;
}
int solvew(int x){
int l = 0, r = m + 1;
while(r - l > 1){
int mid = (l + r) / 2;
if(solve(x, mid)) l = mid;
else r = mid;
}
return l;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
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' + a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
}
}
int ret = 0;
for(int i = 1; i <= n && solve(i, 1); i++){
int x = solvew(i);
i = solveh(x);
ret = max(ret, x * i);
}
cout << ret << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
24828 KB |
Output is correct |
2 |
Correct |
64 ms |
24952 KB |
Output is correct |
3 |
Correct |
72 ms |
34936 KB |
Output is correct |
4 |
Correct |
68 ms |
34936 KB |
Output is correct |
5 |
Correct |
66 ms |
24952 KB |
Output is correct |
6 |
Correct |
54 ms |
24824 KB |
Output is correct |
7 |
Correct |
47 ms |
24824 KB |
Output is correct |
8 |
Correct |
100 ms |
24972 KB |
Output is correct |
9 |
Correct |
125 ms |
24952 KB |
Output is correct |
10 |
Correct |
93 ms |
24944 KB |
Output is correct |
11 |
Correct |
87 ms |
24952 KB |
Output is correct |
12 |
Correct |
76 ms |
24948 KB |
Output is correct |
13 |
Correct |
48 ms |
24952 KB |
Output is correct |
14 |
Correct |
42 ms |
24952 KB |
Output is correct |
15 |
Correct |
93 ms |
24952 KB |
Output is correct |
16 |
Correct |
44 ms |
24952 KB |
Output is correct |
17 |
Correct |
52 ms |
25080 KB |
Output is correct |
18 |
Correct |
161 ms |
25228 KB |
Output is correct |
19 |
Correct |
107 ms |
25300 KB |
Output is correct |
20 |
Correct |
107 ms |
25332 KB |
Output is correct |
21 |
Correct |
143 ms |
25080 KB |
Output is correct |
22 |
Correct |
225 ms |
25336 KB |
Output is correct |
23 |
Correct |
174 ms |
25208 KB |
Output is correct |
24 |
Correct |
93 ms |
25284 KB |
Output is correct |
25 |
Correct |
121 ms |
25336 KB |
Output is correct |
26 |
Correct |
48 ms |
25336 KB |
Output is correct |
27 |
Correct |
89 ms |
26488 KB |
Output is correct |
28 |
Correct |
414 ms |
26488 KB |
Output is correct |
29 |
Execution timed out |
1075 ms |
26872 KB |
Time limit exceeded |
30 |
Correct |
249 ms |
27384 KB |
Output is correct |
31 |
Correct |
275 ms |
26872 KB |
Output is correct |
32 |
Correct |
244 ms |
27132 KB |
Output is correct |
33 |
Correct |
262 ms |
27512 KB |
Output is correct |
34 |
Correct |
329 ms |
26648 KB |
Output is correct |
35 |
Correct |
359 ms |
27512 KB |
Output is correct |
36 |
Correct |
175 ms |
27512 KB |
Output is correct |
37 |
Correct |
182 ms |
24972 KB |
Output is correct |
38 |
Correct |
880 ms |
49368 KB |
Output is correct |
39 |
Correct |
86 ms |
24952 KB |
Output is correct |
40 |
Correct |
520 ms |
31452 KB |
Output is correct |
41 |
Correct |
172 ms |
25080 KB |
Output is correct |
42 |
Correct |
969 ms |
25340 KB |
Output is correct |
43 |
Execution timed out |
1068 ms |
49400 KB |
Time limit exceeded |
44 |
Execution timed out |
1074 ms |
27512 KB |
Time limit exceeded |
45 |
Execution timed out |
1082 ms |
49404 KB |
Time limit exceeded |
46 |
Correct |
959 ms |
49376 KB |
Output is correct |
47 |
Execution timed out |
1084 ms |
49272 KB |
Time limit exceeded |
48 |
Execution timed out |
1068 ms |
49400 KB |
Time limit exceeded |
49 |
Execution timed out |
1084 ms |
49400 KB |
Time limit exceeded |
50 |
Execution timed out |
1076 ms |
49404 KB |
Time limit exceeded |
51 |
Execution timed out |
1087 ms |
49272 KB |
Time limit exceeded |
52 |
Execution timed out |
1084 ms |
49400 KB |
Time limit exceeded |
53 |
Execution timed out |
1078 ms |
49316 KB |
Time limit exceeded |
54 |
Execution timed out |
1077 ms |
49400 KB |
Time limit exceeded |
55 |
Execution timed out |
1063 ms |
49384 KB |
Time limit exceeded |
56 |
Correct |
891 ms |
49400 KB |
Output is correct |
57 |
Execution timed out |
1084 ms |
49272 KB |
Time limit exceeded |
58 |
Execution timed out |
1087 ms |
49400 KB |
Time limit exceeded |
59 |
Execution timed out |
1080 ms |
49416 KB |
Time limit exceeded |
60 |
Execution timed out |
1032 ms |
49368 KB |
Time limit exceeded |
61 |
Execution timed out |
1076 ms |
49272 KB |
Time limit exceeded |
62 |
Execution timed out |
1073 ms |
49356 KB |
Time limit exceeded |
63 |
Execution timed out |
1073 ms |
49400 KB |
Time limit exceeded |
64 |
Correct |
995 ms |
49528 KB |
Output is correct |
65 |
Execution timed out |
1089 ms |
49348 KB |
Time limit exceeded |
66 |
Execution timed out |
1062 ms |
49400 KB |
Time limit exceeded |
67 |
Execution timed out |
1086 ms |
49272 KB |
Time limit exceeded |
68 |
Execution timed out |
1080 ms |
49536 KB |
Time limit exceeded |
69 |
Execution timed out |
1082 ms |
49300 KB |
Time limit exceeded |
70 |
Execution timed out |
1073 ms |
44408 KB |
Time limit exceeded |
71 |
Execution timed out |
1083 ms |
49400 KB |
Time limit exceeded |
72 |
Execution timed out |
1073 ms |
49404 KB |
Time limit exceeded |
73 |
Execution timed out |
1092 ms |
49272 KB |
Time limit exceeded |
74 |
Execution timed out |
1086 ms |
49400 KB |
Time limit exceeded |
75 |
Execution timed out |
1070 ms |
49336 KB |
Time limit exceeded |
76 |
Execution timed out |
1092 ms |
49272 KB |
Time limit exceeded |
77 |
Execution timed out |
1084 ms |
49348 KB |
Time limit exceeded |
78 |
Execution timed out |
1085 ms |
49272 KB |
Time limit exceeded |
79 |
Execution timed out |
1083 ms |
49320 KB |
Time limit exceeded |
80 |
Execution timed out |
1074 ms |
49296 KB |
Time limit exceeded |
81 |
Execution timed out |
1075 ms |
49272 KB |
Time limit exceeded |
82 |
Execution timed out |
1081 ms |
49400 KB |
Time limit exceeded |
83 |
Execution timed out |
1079 ms |
49272 KB |
Time limit exceeded |
84 |
Execution timed out |
1083 ms |
49272 KB |
Time limit exceeded |
85 |
Execution timed out |
1083 ms |
49272 KB |
Time limit exceeded |
86 |
Execution timed out |
1080 ms |
49272 KB |
Time limit exceeded |
87 |
Execution timed out |
1078 ms |
49368 KB |
Time limit exceeded |
88 |
Execution timed out |
1078 ms |
49400 KB |
Time limit exceeded |
89 |
Execution timed out |
1082 ms |
49272 KB |
Time limit exceeded |
90 |
Execution timed out |
1080 ms |
44408 KB |
Time limit exceeded |
91 |
Execution timed out |
1077 ms |
49272 KB |
Time limit exceeded |
92 |
Execution timed out |
1063 ms |
49400 KB |
Time limit exceeded |
93 |
Execution timed out |
1088 ms |
49272 KB |
Time limit exceeded |
94 |
Execution timed out |
1073 ms |
49272 KB |
Time limit exceeded |
95 |
Execution timed out |
1087 ms |
49272 KB |
Time limit exceeded |
96 |
Execution timed out |
1085 ms |
49400 KB |
Time limit exceeded |
97 |
Execution timed out |
1080 ms |
49364 KB |
Time limit exceeded |
98 |
Execution timed out |
1076 ms |
49272 KB |
Time limit exceeded |
99 |
Execution timed out |
1088 ms |
49276 KB |
Time limit exceeded |
100 |
Execution timed out |
1091 ms |
49272 KB |
Time limit exceeded |