#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(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 h = solveh(1), w = solvew(1);
int ret = max(h * solvew(h), w * solveh(w));
cout << ret << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
24824 KB |
Output is correct |
2 |
Correct |
48 ms |
24952 KB |
Output is correct |
3 |
Correct |
94 ms |
34932 KB |
Output is correct |
4 |
Correct |
118 ms |
34936 KB |
Output is correct |
5 |
Correct |
89 ms |
24824 KB |
Output is correct |
6 |
Correct |
77 ms |
24824 KB |
Output is correct |
7 |
Correct |
49 ms |
24824 KB |
Output is correct |
8 |
Incorrect |
52 ms |
24964 KB |
Output isn't correct |
9 |
Incorrect |
56 ms |
24952 KB |
Output isn't correct |
10 |
Correct |
57 ms |
24824 KB |
Output is correct |
11 |
Incorrect |
57 ms |
25080 KB |
Output isn't correct |
12 |
Correct |
52 ms |
24952 KB |
Output is correct |
13 |
Correct |
54 ms |
24952 KB |
Output is correct |
14 |
Correct |
59 ms |
24952 KB |
Output is correct |
15 |
Incorrect |
58 ms |
24952 KB |
Output isn't correct |
16 |
Correct |
57 ms |
24952 KB |
Output is correct |
17 |
Correct |
79 ms |
25080 KB |
Output is correct |
18 |
Incorrect |
69 ms |
25208 KB |
Output isn't correct |
19 |
Incorrect |
76 ms |
25336 KB |
Output isn't correct |
20 |
Incorrect |
89 ms |
25296 KB |
Output isn't correct |
21 |
Incorrect |
64 ms |
25084 KB |
Output isn't correct |
22 |
Incorrect |
76 ms |
25208 KB |
Output isn't correct |
23 |
Incorrect |
88 ms |
25336 KB |
Output isn't correct |
24 |
Incorrect |
69 ms |
25208 KB |
Output isn't correct |
25 |
Incorrect |
101 ms |
25368 KB |
Output isn't correct |
26 |
Correct |
93 ms |
25336 KB |
Output is correct |
27 |
Correct |
121 ms |
26360 KB |
Output is correct |
28 |
Incorrect |
146 ms |
26624 KB |
Output isn't correct |
29 |
Incorrect |
139 ms |
27000 KB |
Output isn't correct |
30 |
Incorrect |
177 ms |
27640 KB |
Output isn't correct |
31 |
Incorrect |
145 ms |
27000 KB |
Output isn't correct |
32 |
Incorrect |
183 ms |
27256 KB |
Output isn't correct |
33 |
Incorrect |
184 ms |
27720 KB |
Output isn't correct |
34 |
Incorrect |
118 ms |
26744 KB |
Output isn't correct |
35 |
Incorrect |
156 ms |
27640 KB |
Output isn't correct |
36 |
Correct |
173 ms |
27640 KB |
Output is correct |
37 |
Correct |
49 ms |
24952 KB |
Output is correct |
38 |
Execution timed out |
1071 ms |
49784 KB |
Time limit exceeded |
39 |
Correct |
58 ms |
24892 KB |
Output is correct |
40 |
Correct |
325 ms |
31736 KB |
Output is correct |
41 |
Correct |
63 ms |
24952 KB |
Output is correct |
42 |
Incorrect |
93 ms |
25336 KB |
Output isn't correct |
43 |
Execution timed out |
1070 ms |
49960 KB |
Time limit exceeded |
44 |
Incorrect |
169 ms |
27768 KB |
Output isn't correct |
45 |
Execution timed out |
1083 ms |
49784 KB |
Time limit exceeded |
46 |
Execution timed out |
1067 ms |
49896 KB |
Time limit exceeded |
47 |
Execution timed out |
1082 ms |
49784 KB |
Time limit exceeded |
48 |
Execution timed out |
1083 ms |
49784 KB |
Time limit exceeded |
49 |
Execution timed out |
1078 ms |
49784 KB |
Time limit exceeded |
50 |
Execution timed out |
1089 ms |
49756 KB |
Time limit exceeded |
51 |
Execution timed out |
1081 ms |
50040 KB |
Time limit exceeded |
52 |
Execution timed out |
1073 ms |
50040 KB |
Time limit exceeded |
53 |
Execution timed out |
1056 ms |
49912 KB |
Time limit exceeded |
54 |
Execution timed out |
1067 ms |
50040 KB |
Time limit exceeded |
55 |
Execution timed out |
1087 ms |
50040 KB |
Time limit exceeded |
56 |
Execution timed out |
1082 ms |
49916 KB |
Time limit exceeded |
57 |
Execution timed out |
1081 ms |
49912 KB |
Time limit exceeded |
58 |
Execution timed out |
1083 ms |
50064 KB |
Time limit exceeded |
59 |
Execution timed out |
1084 ms |
49876 KB |
Time limit exceeded |
60 |
Execution timed out |
1081 ms |
49912 KB |
Time limit exceeded |
61 |
Execution timed out |
1083 ms |
49932 KB |
Time limit exceeded |
62 |
Execution timed out |
1072 ms |
49976 KB |
Time limit exceeded |
63 |
Execution timed out |
1085 ms |
49820 KB |
Time limit exceeded |
64 |
Execution timed out |
1073 ms |
49784 KB |
Time limit exceeded |
65 |
Execution timed out |
1064 ms |
49856 KB |
Time limit exceeded |
66 |
Execution timed out |
1071 ms |
49784 KB |
Time limit exceeded |
67 |
Execution timed out |
1086 ms |
49784 KB |
Time limit exceeded |
68 |
Execution timed out |
1090 ms |
49788 KB |
Time limit exceeded |
69 |
Execution timed out |
1051 ms |
49768 KB |
Time limit exceeded |
70 |
Execution timed out |
1090 ms |
44920 KB |
Time limit exceeded |
71 |
Execution timed out |
1075 ms |
49796 KB |
Time limit exceeded |
72 |
Execution timed out |
1087 ms |
49784 KB |
Time limit exceeded |
73 |
Execution timed out |
1081 ms |
49836 KB |
Time limit exceeded |
74 |
Execution timed out |
1086 ms |
49788 KB |
Time limit exceeded |
75 |
Execution timed out |
1085 ms |
49912 KB |
Time limit exceeded |
76 |
Execution timed out |
1084 ms |
50016 KB |
Time limit exceeded |
77 |
Execution timed out |
1083 ms |
49912 KB |
Time limit exceeded |
78 |
Execution timed out |
1075 ms |
49528 KB |
Time limit exceeded |
79 |
Execution timed out |
1094 ms |
49272 KB |
Time limit exceeded |
80 |
Execution timed out |
1092 ms |
49400 KB |
Time limit exceeded |
81 |
Execution timed out |
1088 ms |
49540 KB |
Time limit exceeded |
82 |
Execution timed out |
1088 ms |
49272 KB |
Time limit exceeded |
83 |
Execution timed out |
1083 ms |
49272 KB |
Time limit exceeded |
84 |
Execution timed out |
1082 ms |
49272 KB |
Time limit exceeded |
85 |
Execution timed out |
1087 ms |
49272 KB |
Time limit exceeded |
86 |
Execution timed out |
1087 ms |
49332 KB |
Time limit exceeded |
87 |
Execution timed out |
1081 ms |
49272 KB |
Time limit exceeded |
88 |
Execution timed out |
1069 ms |
49352 KB |
Time limit exceeded |
89 |
Execution timed out |
1089 ms |
49276 KB |
Time limit exceeded |
90 |
Execution timed out |
1077 ms |
44544 KB |
Time limit exceeded |
91 |
Execution timed out |
1078 ms |
49272 KB |
Time limit exceeded |
92 |
Execution timed out |
1081 ms |
49272 KB |
Time limit exceeded |
93 |
Execution timed out |
1082 ms |
49400 KB |
Time limit exceeded |
94 |
Execution timed out |
1076 ms |
49272 KB |
Time limit exceeded |
95 |
Execution timed out |
1082 ms |
49272 KB |
Time limit exceeded |
96 |
Execution timed out |
1090 ms |
49272 KB |
Time limit exceeded |
97 |
Execution timed out |
1093 ms |
49272 KB |
Time limit exceeded |
98 |
Execution timed out |
1087 ms |
49272 KB |
Time limit exceeded |
99 |
Execution timed out |
1084 ms |
49272 KB |
Time limit exceeded |
100 |
Execution timed out |
1058 ms |
49520 KB |
Time limit exceeded |