#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];
bool solve(int x, int y){
int b[maxn][maxn];
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(x, mid)) 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(mid, x)) 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 h = solveh(1), w = solvew(1);
int ret = max(h * solvew(h), w * solveh(w));
cout << ret << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
46 ms |
24884 KB |
Output isn't correct |
2 |
Incorrect |
46 ms |
24952 KB |
Output isn't correct |
3 |
Incorrect |
112 ms |
34808 KB |
Output isn't correct |
4 |
Incorrect |
92 ms |
35064 KB |
Output isn't correct |
5 |
Incorrect |
66 ms |
24824 KB |
Output isn't correct |
6 |
Incorrect |
70 ms |
24884 KB |
Output isn't correct |
7 |
Correct |
46 ms |
24888 KB |
Output is correct |
8 |
Incorrect |
58 ms |
24968 KB |
Output isn't correct |
9 |
Incorrect |
50 ms |
24952 KB |
Output isn't correct |
10 |
Correct |
56 ms |
24952 KB |
Output is correct |
11 |
Incorrect |
52 ms |
24952 KB |
Output isn't correct |
12 |
Correct |
52 ms |
24824 KB |
Output is correct |
13 |
Correct |
63 ms |
24952 KB |
Output is correct |
14 |
Correct |
49 ms |
24824 KB |
Output is correct |
15 |
Incorrect |
57 ms |
24988 KB |
Output isn't correct |
16 |
Correct |
67 ms |
24960 KB |
Output is correct |
17 |
Correct |
97 ms |
25080 KB |
Output is correct |
18 |
Incorrect |
69 ms |
25080 KB |
Output isn't correct |
19 |
Incorrect |
75 ms |
25208 KB |
Output isn't correct |
20 |
Incorrect |
82 ms |
25292 KB |
Output isn't correct |
21 |
Incorrect |
67 ms |
25052 KB |
Output isn't correct |
22 |
Incorrect |
168 ms |
25208 KB |
Output isn't correct |
23 |
Incorrect |
74 ms |
25336 KB |
Output isn't correct |
24 |
Incorrect |
96 ms |
25208 KB |
Output isn't correct |
25 |
Incorrect |
80 ms |
25208 KB |
Output isn't correct |
26 |
Correct |
76 ms |
25336 KB |
Output is correct |
27 |
Correct |
103 ms |
26360 KB |
Output is correct |
28 |
Incorrect |
124 ms |
26624 KB |
Output isn't correct |
29 |
Incorrect |
173 ms |
27128 KB |
Output isn't correct |
30 |
Incorrect |
209 ms |
27528 KB |
Output isn't correct |
31 |
Incorrect |
191 ms |
27000 KB |
Output isn't correct |
32 |
Incorrect |
201 ms |
27260 KB |
Output isn't correct |
33 |
Incorrect |
197 ms |
27640 KB |
Output isn't correct |
34 |
Incorrect |
156 ms |
26712 KB |
Output isn't correct |
35 |
Incorrect |
196 ms |
27688 KB |
Output isn't correct |
36 |
Correct |
199 ms |
27640 KB |
Output is correct |
37 |
Correct |
68 ms |
24952 KB |
Output is correct |
38 |
Execution timed out |
1070 ms |
50040 KB |
Time limit exceeded |
39 |
Correct |
67 ms |
25080 KB |
Output is correct |
40 |
Correct |
348 ms |
31828 KB |
Output is correct |
41 |
Correct |
63 ms |
24952 KB |
Output is correct |
42 |
Incorrect |
92 ms |
25336 KB |
Output isn't correct |
43 |
Execution timed out |
1049 ms |
49912 KB |
Time limit exceeded |
44 |
Incorrect |
191 ms |
27640 KB |
Output isn't correct |
45 |
Execution timed out |
1070 ms |
49936 KB |
Time limit exceeded |
46 |
Execution timed out |
1081 ms |
49912 KB |
Time limit exceeded |
47 |
Execution timed out |
1064 ms |
49912 KB |
Time limit exceeded |
48 |
Execution timed out |
1067 ms |
50040 KB |
Time limit exceeded |
49 |
Execution timed out |
1084 ms |
49916 KB |
Time limit exceeded |
50 |
Execution timed out |
1070 ms |
50308 KB |
Time limit exceeded |
51 |
Execution timed out |
1080 ms |
50168 KB |
Time limit exceeded |
52 |
Execution timed out |
1076 ms |
50296 KB |
Time limit exceeded |
53 |
Execution timed out |
1057 ms |
50216 KB |
Time limit exceeded |
54 |
Execution timed out |
1068 ms |
50396 KB |
Time limit exceeded |
55 |
Execution timed out |
1057 ms |
50168 KB |
Time limit exceeded |
56 |
Execution timed out |
1057 ms |
50296 KB |
Time limit exceeded |
57 |
Execution timed out |
1052 ms |
50168 KB |
Time limit exceeded |
58 |
Execution timed out |
1082 ms |
50140 KB |
Time limit exceeded |
59 |
Execution timed out |
1079 ms |
50056 KB |
Time limit exceeded |
60 |
Execution timed out |
1067 ms |
50168 KB |
Time limit exceeded |
61 |
Execution timed out |
1080 ms |
50168 KB |
Time limit exceeded |
62 |
Execution timed out |
1055 ms |
50168 KB |
Time limit exceeded |
63 |
Execution timed out |
1075 ms |
49916 KB |
Time limit exceeded |
64 |
Execution timed out |
1076 ms |
49912 KB |
Time limit exceeded |
65 |
Execution timed out |
1083 ms |
50040 KB |
Time limit exceeded |
66 |
Execution timed out |
1083 ms |
49912 KB |
Time limit exceeded |
67 |
Execution timed out |
1068 ms |
50140 KB |
Time limit exceeded |
68 |
Execution timed out |
1064 ms |
50032 KB |
Time limit exceeded |
69 |
Execution timed out |
1055 ms |
49912 KB |
Time limit exceeded |
70 |
Execution timed out |
1085 ms |
45052 KB |
Time limit exceeded |
71 |
Execution timed out |
1079 ms |
50132 KB |
Time limit exceeded |
72 |
Execution timed out |
1075 ms |
49912 KB |
Time limit exceeded |
73 |
Execution timed out |
1071 ms |
50040 KB |
Time limit exceeded |
74 |
Execution timed out |
1080 ms |
49912 KB |
Time limit exceeded |
75 |
Execution timed out |
1088 ms |
49912 KB |
Time limit exceeded |
76 |
Execution timed out |
1039 ms |
49968 KB |
Time limit exceeded |
77 |
Execution timed out |
1075 ms |
50040 KB |
Time limit exceeded |
78 |
Execution timed out |
1071 ms |
49912 KB |
Time limit exceeded |
79 |
Execution timed out |
1062 ms |
50440 KB |
Time limit exceeded |
80 |
Execution timed out |
1072 ms |
50460 KB |
Time limit exceeded |
81 |
Execution timed out |
1055 ms |
50492 KB |
Time limit exceeded |
82 |
Execution timed out |
1078 ms |
50396 KB |
Time limit exceeded |
83 |
Execution timed out |
1074 ms |
50412 KB |
Time limit exceeded |
84 |
Execution timed out |
1084 ms |
50472 KB |
Time limit exceeded |
85 |
Execution timed out |
1069 ms |
50528 KB |
Time limit exceeded |
86 |
Execution timed out |
1086 ms |
50424 KB |
Time limit exceeded |
87 |
Execution timed out |
1026 ms |
50424 KB |
Time limit exceeded |
88 |
Execution timed out |
1084 ms |
50424 KB |
Time limit exceeded |
89 |
Execution timed out |
1086 ms |
50428 KB |
Time limit exceeded |
90 |
Execution timed out |
1091 ms |
45588 KB |
Time limit exceeded |
91 |
Execution timed out |
1063 ms |
50424 KB |
Time limit exceeded |
92 |
Execution timed out |
1051 ms |
50424 KB |
Time limit exceeded |
93 |
Execution timed out |
1020 ms |
50424 KB |
Time limit exceeded |
94 |
Execution timed out |
1069 ms |
50424 KB |
Time limit exceeded |
95 |
Execution timed out |
1083 ms |
50424 KB |
Time limit exceeded |
96 |
Execution timed out |
1048 ms |
50424 KB |
Time limit exceeded |
97 |
Execution timed out |
1042 ms |
50492 KB |
Time limit exceeded |
98 |
Execution timed out |
1073 ms |
50424 KB |
Time limit exceeded |
99 |
Execution timed out |
1059 ms |
50552 KB |
Time limit exceeded |
100 |
Execution timed out |
1079 ms |
50552 KB |
Time limit exceeded |