#include <bits/stdc++.h>
using namespace std;
const int N = 2505;
int n, m, a[N][N], b[N][N], c[N][N], d[N][N];
char e[N][N];
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> e[i][j];
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(e[i][j] == '1'){
a[i][j] = a[i][j-1] + 1;
}
else {
a[i][j] = 0;
}
}
}
for(int i = 1; i <= n; i++){
for(int j = m; j >= 1; j--){
if(e[i][j] == '1'){
b[i][j] = b[i][j+1] + 1;
}
else {
b[i][j] = 0;
}
}
}
for(int j = 1; j <= m; j++){
for(int i = 1; i <= n; i++){
if(e[i][j] == '1'){
c[i][j] = c[i-1][j] + 1;
}
else {
c[i][j] = 0;
}
}
}
for(int j = 1; j <= m; j++){
for(int i = n; i >= 1; i--){
if(e[i][j] == '1'){
d[i][j] = d[i+1][j] + 1;
}
else {
d[i][j] = 0;
}
}
}
int n1 = 1e9, m1 = 1e9;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(e[i][j] == '0') continue;
n1 = min(n1, (c[i][j] + d[i][j]) - 1);
m1 = min(m1, (a[i][j] + b[i][j]) - 1);
}
}
if(n1 == 1e9 and m1 == 1e9) cout << 0;
else cout << n1*m1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8528 KB |
Output is correct |
2 |
Correct |
2 ms |
2808 KB |
Output is correct |
3 |
Correct |
22 ms |
73296 KB |
Output is correct |
4 |
Correct |
26 ms |
66128 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Incorrect |
2 ms |
4688 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
4688 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
6656 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
4688 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
4688 KB |
Output isn't correct |
13 |
Correct |
2 ms |
8528 KB |
Output is correct |
14 |
Correct |
1 ms |
4688 KB |
Output is correct |
15 |
Incorrect |
2 ms |
4708 KB |
Output isn't correct |
16 |
Correct |
1 ms |
2640 KB |
Output is correct |
17 |
Correct |
2 ms |
16976 KB |
Output is correct |
18 |
Incorrect |
3 ms |
13304 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
15184 KB |
Output isn't correct |
20 |
Incorrect |
4 ms |
15184 KB |
Output isn't correct |
21 |
Incorrect |
3 ms |
16976 KB |
Output isn't correct |
22 |
Incorrect |
4 ms |
19192 KB |
Output isn't correct |
23 |
Incorrect |
3 ms |
15184 KB |
Output isn't correct |
24 |
Incorrect |
3 ms |
15184 KB |
Output isn't correct |
25 |
Incorrect |
4 ms |
15184 KB |
Output isn't correct |
26 |
Correct |
3 ms |
8016 KB |
Output is correct |
27 |
Correct |
8 ms |
14416 KB |
Output is correct |
28 |
Incorrect |
7 ms |
23800 KB |
Output isn't correct |
29 |
Incorrect |
8 ms |
25936 KB |
Output isn't correct |
30 |
Incorrect |
18 ms |
22608 KB |
Output isn't correct |
31 |
Incorrect |
10 ms |
22640 KB |
Output isn't correct |
32 |
Incorrect |
9 ms |
22644 KB |
Output isn't correct |
33 |
Incorrect |
11 ms |
26704 KB |
Output isn't correct |
34 |
Incorrect |
7 ms |
27216 KB |
Output isn't correct |
35 |
Incorrect |
13 ms |
27472 KB |
Output isn't correct |
36 |
Correct |
15 ms |
20304 KB |
Output is correct |
37 |
Incorrect |
1 ms |
6912 KB |
Output isn't correct |
38 |
Correct |
257 ms |
104548 KB |
Output is correct |
39 |
Incorrect |
1 ms |
6736 KB |
Output isn't correct |
40 |
Incorrect |
37 ms |
36992 KB |
Output isn't correct |
41 |
Incorrect |
1 ms |
6908 KB |
Output isn't correct |
42 |
Incorrect |
3 ms |
13648 KB |
Output isn't correct |
43 |
Correct |
303 ms |
104560 KB |
Output is correct |
44 |
Incorrect |
13 ms |
25736 KB |
Output isn't correct |
45 |
Incorrect |
257 ms |
105188 KB |
Output isn't correct |
46 |
Correct |
360 ms |
104988 KB |
Output is correct |
47 |
Incorrect |
250 ms |
104552 KB |
Output isn't correct |
48 |
Incorrect |
240 ms |
104976 KB |
Output isn't correct |
49 |
Correct |
249 ms |
104560 KB |
Output is correct |
50 |
Incorrect |
257 ms |
104556 KB |
Output isn't correct |
51 |
Incorrect |
240 ms |
104864 KB |
Output isn't correct |
52 |
Incorrect |
235 ms |
104864 KB |
Output isn't correct |
53 |
Incorrect |
225 ms |
104556 KB |
Output isn't correct |
54 |
Incorrect |
225 ms |
104520 KB |
Output isn't correct |
55 |
Incorrect |
247 ms |
105092 KB |
Output isn't correct |
56 |
Correct |
248 ms |
104552 KB |
Output is correct |
57 |
Incorrect |
252 ms |
105440 KB |
Output isn't correct |
58 |
Incorrect |
259 ms |
104520 KB |
Output isn't correct |
59 |
Incorrect |
245 ms |
105144 KB |
Output isn't correct |
60 |
Correct |
263 ms |
104552 KB |
Output is correct |
61 |
Correct |
256 ms |
105032 KB |
Output is correct |
62 |
Correct |
246 ms |
104520 KB |
Output is correct |
63 |
Correct |
253 ms |
104556 KB |
Output is correct |
64 |
Correct |
257 ms |
104520 KB |
Output is correct |
65 |
Incorrect |
264 ms |
104556 KB |
Output isn't correct |
66 |
Incorrect |
260 ms |
104548 KB |
Output isn't correct |
67 |
Incorrect |
259 ms |
104720 KB |
Output isn't correct |
68 |
Incorrect |
240 ms |
104556 KB |
Output isn't correct |
69 |
Incorrect |
248 ms |
104556 KB |
Output isn't correct |
70 |
Incorrect |
156 ms |
91488 KB |
Output isn't correct |
71 |
Incorrect |
227 ms |
104548 KB |
Output isn't correct |
72 |
Incorrect |
228 ms |
104524 KB |
Output isn't correct |
73 |
Incorrect |
243 ms |
104556 KB |
Output isn't correct |
74 |
Incorrect |
238 ms |
104556 KB |
Output isn't correct |
75 |
Incorrect |
238 ms |
105832 KB |
Output isn't correct |
76 |
Incorrect |
244 ms |
104816 KB |
Output isn't correct |
77 |
Incorrect |
233 ms |
104556 KB |
Output isn't correct |
78 |
Incorrect |
239 ms |
104552 KB |
Output isn't correct |
79 |
Incorrect |
241 ms |
104520 KB |
Output isn't correct |
80 |
Incorrect |
232 ms |
104552 KB |
Output isn't correct |
81 |
Incorrect |
235 ms |
104568 KB |
Output isn't correct |
82 |
Incorrect |
230 ms |
104520 KB |
Output isn't correct |
83 |
Incorrect |
231 ms |
104520 KB |
Output isn't correct |
84 |
Incorrect |
235 ms |
104520 KB |
Output isn't correct |
85 |
Incorrect |
230 ms |
104520 KB |
Output isn't correct |
86 |
Incorrect |
229 ms |
104556 KB |
Output isn't correct |
87 |
Incorrect |
225 ms |
104520 KB |
Output isn't correct |
88 |
Incorrect |
227 ms |
104520 KB |
Output isn't correct |
89 |
Incorrect |
223 ms |
104560 KB |
Output isn't correct |
90 |
Incorrect |
145 ms |
90220 KB |
Output isn't correct |
91 |
Incorrect |
223 ms |
104520 KB |
Output isn't correct |
92 |
Incorrect |
228 ms |
104524 KB |
Output isn't correct |
93 |
Incorrect |
229 ms |
104520 KB |
Output isn't correct |
94 |
Incorrect |
233 ms |
104816 KB |
Output isn't correct |
95 |
Incorrect |
229 ms |
104520 KB |
Output isn't correct |
96 |
Incorrect |
214 ms |
104556 KB |
Output isn't correct |
97 |
Incorrect |
242 ms |
104560 KB |
Output isn't correct |
98 |
Incorrect |
232 ms |
104556 KB |
Output isn't correct |
99 |
Incorrect |
266 ms |
104560 KB |
Output isn't correct |
100 |
Incorrect |
257 ms |
104556 KB |
Output isn't correct |