#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 = n + 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 ret = max(solveh(1) * solvew(solveh(1)), solvew(1) * solveh(solvew(1)));
cout << ret << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
41 ms |
24824 KB |
Output isn't correct |
2 |
Correct |
81 ms |
24952 KB |
Output is correct |
3 |
Correct |
245 ms |
34936 KB |
Output is correct |
4 |
Correct |
212 ms |
34936 KB |
Output is correct |
5 |
Incorrect |
37 ms |
25004 KB |
Output isn't correct |
6 |
Incorrect |
34 ms |
24824 KB |
Output isn't correct |
7 |
Correct |
60 ms |
24824 KB |
Output is correct |
8 |
Incorrect |
117 ms |
24952 KB |
Output isn't correct |
9 |
Incorrect |
78 ms |
24952 KB |
Output isn't correct |
10 |
Correct |
81 ms |
24824 KB |
Output is correct |
11 |
Incorrect |
85 ms |
24940 KB |
Output isn't correct |
12 |
Correct |
103 ms |
24952 KB |
Output is correct |
13 |
Correct |
76 ms |
24824 KB |
Output is correct |
14 |
Correct |
91 ms |
24952 KB |
Output is correct |
15 |
Incorrect |
107 ms |
24952 KB |
Output isn't correct |
16 |
Correct |
112 ms |
24952 KB |
Output is correct |
17 |
Correct |
125 ms |
25208 KB |
Output is correct |
18 |
Incorrect |
138 ms |
25208 KB |
Output isn't correct |
19 |
Incorrect |
140 ms |
25208 KB |
Output isn't correct |
20 |
Incorrect |
157 ms |
25236 KB |
Output isn't correct |
21 |
Incorrect |
148 ms |
25080 KB |
Output isn't correct |
22 |
Incorrect |
118 ms |
25208 KB |
Output isn't correct |
23 |
Incorrect |
148 ms |
25464 KB |
Output isn't correct |
24 |
Incorrect |
126 ms |
25208 KB |
Output isn't correct |
25 |
Incorrect |
181 ms |
25436 KB |
Output isn't correct |
26 |
Correct |
161 ms |
25336 KB |
Output is correct |
27 |
Correct |
220 ms |
26452 KB |
Output is correct |
28 |
Incorrect |
237 ms |
26616 KB |
Output isn't correct |
29 |
Incorrect |
220 ms |
26972 KB |
Output isn't correct |
30 |
Incorrect |
260 ms |
27548 KB |
Output isn't correct |
31 |
Incorrect |
273 ms |
26872 KB |
Output isn't correct |
32 |
Incorrect |
223 ms |
27256 KB |
Output isn't correct |
33 |
Incorrect |
338 ms |
27740 KB |
Output isn't correct |
34 |
Incorrect |
172 ms |
26820 KB |
Output isn't correct |
35 |
Incorrect |
259 ms |
27640 KB |
Output isn't correct |
36 |
Correct |
425 ms |
27768 KB |
Output is correct |
37 |
Correct |
123 ms |
25080 KB |
Output is correct |
38 |
Execution timed out |
1075 ms |
51576 KB |
Time limit exceeded |
39 |
Correct |
184 ms |
24952 KB |
Output is correct |
40 |
Correct |
492 ms |
32200 KB |
Output is correct |
41 |
Correct |
88 ms |
24952 KB |
Output is correct |
42 |
Incorrect |
118 ms |
25212 KB |
Output isn't correct |
43 |
Execution timed out |
1088 ms |
51512 KB |
Time limit exceeded |
44 |
Incorrect |
205 ms |
27640 KB |
Output isn't correct |
45 |
Execution timed out |
1081 ms |
51052 KB |
Time limit exceeded |
46 |
Execution timed out |
1091 ms |
51064 KB |
Time limit exceeded |
47 |
Execution timed out |
1078 ms |
51544 KB |
Time limit exceeded |
48 |
Execution timed out |
1042 ms |
51452 KB |
Time limit exceeded |
49 |
Execution timed out |
1068 ms |
51704 KB |
Time limit exceeded |
50 |
Execution timed out |
1078 ms |
51556 KB |
Time limit exceeded |
51 |
Execution timed out |
1090 ms |
51576 KB |
Time limit exceeded |
52 |
Execution timed out |
1088 ms |
51576 KB |
Time limit exceeded |
53 |
Execution timed out |
1079 ms |
51580 KB |
Time limit exceeded |
54 |
Execution timed out |
1079 ms |
51576 KB |
Time limit exceeded |
55 |
Execution timed out |
1079 ms |
51704 KB |
Time limit exceeded |
56 |
Execution timed out |
1073 ms |
51576 KB |
Time limit exceeded |
57 |
Execution timed out |
1076 ms |
51568 KB |
Time limit exceeded |
58 |
Execution timed out |
1074 ms |
51704 KB |
Time limit exceeded |
59 |
Execution timed out |
1073 ms |
51576 KB |
Time limit exceeded |
60 |
Execution timed out |
1070 ms |
51576 KB |
Time limit exceeded |
61 |
Execution timed out |
1081 ms |
51576 KB |
Time limit exceeded |
62 |
Execution timed out |
1060 ms |
51588 KB |
Time limit exceeded |
63 |
Execution timed out |
1082 ms |
50936 KB |
Time limit exceeded |
64 |
Execution timed out |
1078 ms |
51320 KB |
Time limit exceeded |
65 |
Execution timed out |
1081 ms |
51576 KB |
Time limit exceeded |
66 |
Execution timed out |
1078 ms |
50424 KB |
Time limit exceeded |
67 |
Execution timed out |
1086 ms |
50680 KB |
Time limit exceeded |
68 |
Execution timed out |
1082 ms |
51192 KB |
Time limit exceeded |
69 |
Execution timed out |
1077 ms |
50680 KB |
Time limit exceeded |
70 |
Execution timed out |
1058 ms |
45560 KB |
Time limit exceeded |
71 |
Execution timed out |
1072 ms |
51576 KB |
Time limit exceeded |
72 |
Execution timed out |
1076 ms |
51576 KB |
Time limit exceeded |
73 |
Execution timed out |
1075 ms |
50440 KB |
Time limit exceeded |
74 |
Execution timed out |
1071 ms |
50552 KB |
Time limit exceeded |
75 |
Execution timed out |
1072 ms |
50500 KB |
Time limit exceeded |
76 |
Execution timed out |
1085 ms |
50424 KB |
Time limit exceeded |
77 |
Execution timed out |
1085 ms |
50432 KB |
Time limit exceeded |
78 |
Execution timed out |
1054 ms |
50552 KB |
Time limit exceeded |
79 |
Execution timed out |
1073 ms |
50428 KB |
Time limit exceeded |
80 |
Execution timed out |
1080 ms |
50512 KB |
Time limit exceeded |
81 |
Execution timed out |
1087 ms |
50424 KB |
Time limit exceeded |
82 |
Execution timed out |
1072 ms |
50424 KB |
Time limit exceeded |
83 |
Execution timed out |
1084 ms |
50424 KB |
Time limit exceeded |
84 |
Execution timed out |
1083 ms |
50488 KB |
Time limit exceeded |
85 |
Execution timed out |
1084 ms |
50444 KB |
Time limit exceeded |
86 |
Execution timed out |
1075 ms |
50468 KB |
Time limit exceeded |
87 |
Execution timed out |
1080 ms |
50428 KB |
Time limit exceeded |
88 |
Execution timed out |
1086 ms |
50680 KB |
Time limit exceeded |
89 |
Execution timed out |
1087 ms |
50680 KB |
Time limit exceeded |
90 |
Execution timed out |
1083 ms |
45560 KB |
Time limit exceeded |
91 |
Execution timed out |
1066 ms |
50552 KB |
Time limit exceeded |
92 |
Execution timed out |
1064 ms |
50684 KB |
Time limit exceeded |
93 |
Execution timed out |
1081 ms |
51060 KB |
Time limit exceeded |
94 |
Execution timed out |
1074 ms |
51064 KB |
Time limit exceeded |
95 |
Execution timed out |
1064 ms |
51064 KB |
Time limit exceeded |
96 |
Execution timed out |
1083 ms |
51156 KB |
Time limit exceeded |
97 |
Execution timed out |
1084 ms |
51192 KB |
Time limit exceeded |
98 |
Execution timed out |
1077 ms |
51648 KB |
Time limit exceeded |
99 |
Execution timed out |
1076 ms |
51576 KB |
Time limit exceeded |
100 |
Execution timed out |
1074 ms |
51576 KB |
Time limit exceeded |