#include <bits/stdc++.h>
using namespace std;
int n, m;
const int maxn = 2504;
int chainw[maxn][maxn];
int chainh[maxn][maxn];
int getParentW(int i, int j) {
if (chainw[i][j+1] != 0) return getParentW(i, j+1);
return j;
}
int getParentH(int i, int j) {
if (chainh[i+1][j] != 0) return getParentH(i+1, j);
return i;
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
char x;
cin >> x;
if (x == '1') {
chainw[i][j] = chainw[i][j-1]+1;
chainh[i][j] = chainh[i-1][j]+1;
}
}
}
int maxpossiblew = maxn;
int maxpossibleh = maxn;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
j = getParentW(i, j);
if (chainw[i][j] == 0) continue;
maxpossiblew = min(maxpossiblew, chainw[i][j]);
}
// if (maxw[i] == 0) continue;
// maxpossiblew = min(maxpossiblew, chainw[i][maxw[i]]);
}
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++) {
i = getParentH(i, j);
if (chainh[i][j] == 0) continue;
maxpossibleh = min(maxpossibleh, chainh[i][j]);
}
// if (maxw[i] == 0) continue;
// maxpossiblew = min(maxpossiblew, chainw[i][maxw[i]]);
}
cout << maxpossibleh * maxpossiblew << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
9 ms |
20308 KB |
Output is correct |
4 |
Correct |
10 ms |
20308 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
724 KB |
Output is correct |
18 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
980 KB |
Output isn't correct |
26 |
Correct |
2 ms |
1236 KB |
Output is correct |
27 |
Correct |
4 ms |
3284 KB |
Output is correct |
28 |
Incorrect |
5 ms |
724 KB |
Output isn't correct |
29 |
Incorrect |
6 ms |
4180 KB |
Output isn't correct |
30 |
Incorrect |
8 ms |
3028 KB |
Output isn't correct |
31 |
Incorrect |
7 ms |
2132 KB |
Output isn't correct |
32 |
Incorrect |
7 ms |
3012 KB |
Output isn't correct |
33 |
Incorrect |
9 ms |
4052 KB |
Output isn't correct |
34 |
Incorrect |
4 ms |
724 KB |
Output isn't correct |
35 |
Incorrect |
8 ms |
852 KB |
Output isn't correct |
36 |
Correct |
9 ms |
5460 KB |
Output is correct |
37 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
38 |
Correct |
251 ms |
49292 KB |
Output is correct |
39 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
40 |
Incorrect |
32 ms |
13300 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
42 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
43 |
Correct |
255 ms |
45388 KB |
Output is correct |
44 |
Incorrect |
9 ms |
4944 KB |
Output isn't correct |
45 |
Incorrect |
259 ms |
46780 KB |
Output isn't correct |
46 |
Correct |
268 ms |
49228 KB |
Output is correct |
47 |
Incorrect |
253 ms |
46796 KB |
Output isn't correct |
48 |
Incorrect |
269 ms |
49356 KB |
Output isn't correct |
49 |
Correct |
252 ms |
49268 KB |
Output is correct |
50 |
Incorrect |
263 ms |
49292 KB |
Output isn't correct |
51 |
Incorrect |
262 ms |
49272 KB |
Output isn't correct |
52 |
Incorrect |
262 ms |
49408 KB |
Output isn't correct |
53 |
Incorrect |
261 ms |
48648 KB |
Output isn't correct |
54 |
Incorrect |
258 ms |
35996 KB |
Output isn't correct |
55 |
Incorrect |
254 ms |
34140 KB |
Output isn't correct |
56 |
Correct |
260 ms |
49284 KB |
Output is correct |
57 |
Incorrect |
262 ms |
29264 KB |
Output isn't correct |
58 |
Incorrect |
250 ms |
34288 KB |
Output isn't correct |
59 |
Incorrect |
254 ms |
31180 KB |
Output isn't correct |
60 |
Correct |
260 ms |
41156 KB |
Output is correct |
61 |
Correct |
307 ms |
49300 KB |
Output is correct |
62 |
Correct |
251 ms |
49284 KB |
Output is correct |
63 |
Correct |
257 ms |
49292 KB |
Output is correct |
64 |
Correct |
258 ms |
32080 KB |
Output is correct |
65 |
Incorrect |
268 ms |
48104 KB |
Output isn't correct |
66 |
Incorrect |
263 ms |
45068 KB |
Output isn't correct |
67 |
Incorrect |
257 ms |
49280 KB |
Output isn't correct |
68 |
Incorrect |
256 ms |
49292 KB |
Output isn't correct |
69 |
Incorrect |
253 ms |
28924 KB |
Output isn't correct |
70 |
Incorrect |
154 ms |
10236 KB |
Output isn't correct |
71 |
Incorrect |
244 ms |
21832 KB |
Output isn't correct |
72 |
Incorrect |
256 ms |
27444 KB |
Output isn't correct |
73 |
Incorrect |
249 ms |
27852 KB |
Output isn't correct |
74 |
Incorrect |
256 ms |
29452 KB |
Output isn't correct |
75 |
Incorrect |
255 ms |
30948 KB |
Output isn't correct |
76 |
Incorrect |
266 ms |
32308 KB |
Output isn't correct |
77 |
Incorrect |
252 ms |
32816 KB |
Output isn't correct |
78 |
Incorrect |
251 ms |
33148 KB |
Output isn't correct |
79 |
Incorrect |
235 ms |
5688 KB |
Output isn't correct |
80 |
Incorrect |
262 ms |
6956 KB |
Output isn't correct |
81 |
Incorrect |
235 ms |
7208 KB |
Output isn't correct |
82 |
Incorrect |
255 ms |
35492 KB |
Output isn't correct |
83 |
Incorrect |
252 ms |
35796 KB |
Output isn't correct |
84 |
Incorrect |
236 ms |
980 KB |
Output isn't correct |
85 |
Incorrect |
253 ms |
34568 KB |
Output isn't correct |
86 |
Incorrect |
256 ms |
48176 KB |
Output isn't correct |
87 |
Incorrect |
259 ms |
33552 KB |
Output isn't correct |
88 |
Incorrect |
263 ms |
34508 KB |
Output isn't correct |
89 |
Incorrect |
257 ms |
43176 KB |
Output isn't correct |
90 |
Incorrect |
163 ms |
24552 KB |
Output isn't correct |
91 |
Incorrect |
261 ms |
38448 KB |
Output isn't correct |
92 |
Incorrect |
258 ms |
40016 KB |
Output isn't correct |
93 |
Incorrect |
250 ms |
47160 KB |
Output isn't correct |
94 |
Incorrect |
259 ms |
42060 KB |
Output isn't correct |
95 |
Incorrect |
254 ms |
35820 KB |
Output isn't correct |
96 |
Incorrect |
269 ms |
35408 KB |
Output isn't correct |
97 |
Incorrect |
256 ms |
47948 KB |
Output isn't correct |
98 |
Incorrect |
261 ms |
35472 KB |
Output isn't correct |
99 |
Incorrect |
258 ms |
41492 KB |
Output isn't correct |
100 |
Incorrect |
269 ms |
46792 KB |
Output isn't correct |