#include <bits/stdc++.h>
using namespace std;
const long long INF=1e18;
const int N=2510;
int v[N][N],u[N][N],d[N][N],l[N][N],r[N][N];
int32_t main() {
int n,m;cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char c;cin>>c;
v[i][j]=c-'0';
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(v[i][j]==0){
continue;
}
u[i][j]=u[i-1][j]+1;
l[i][j]=l[i][j-1]+1;
}
}
for(int i=n;i>0;i--){
for(int j=m;j>0;j--){
if(v[i][j]==0){
continue;
}
d[i][j]=d[i+1][j]+1;
r[i][j]=r[i][j+1]+1;
}
}
int a=N,b=N;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(v[i][j]==0){
continue;
}
a=min(a,r[i][j]+l[i][j]-1);
b=min(b,u[i][j]+d[i][j]-1);
//cout<<r[i][j]<<' '<<l[i][j]<<' '<<u[i][j]<<' '<<d[i][j]<<endl;
}
}
cout<<a*b<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4600 KB |
Output is correct |
2 |
Correct |
1 ms |
10584 KB |
Output is correct |
3 |
Correct |
15 ms |
93020 KB |
Output is correct |
4 |
Correct |
16 ms |
93020 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
6576 KB |
Output is correct |
8 |
Incorrect |
2 ms |
10588 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
10840 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
10844 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
10840 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
10840 KB |
Output isn't correct |
13 |
Correct |
1 ms |
10840 KB |
Output is correct |
14 |
Correct |
1 ms |
10844 KB |
Output is correct |
15 |
Incorrect |
2 ms |
10840 KB |
Output isn't correct |
16 |
Correct |
2 ms |
10840 KB |
Output is correct |
17 |
Correct |
2 ms |
11352 KB |
Output is correct |
18 |
Incorrect |
2 ms |
11096 KB |
Output isn't correct |
19 |
Incorrect |
2 ms |
11352 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
11352 KB |
Output isn't correct |
21 |
Incorrect |
2 ms |
10840 KB |
Output isn't correct |
22 |
Incorrect |
2 ms |
11100 KB |
Output isn't correct |
23 |
Incorrect |
2 ms |
11352 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
11352 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
11608 KB |
Output isn't correct |
26 |
Correct |
3 ms |
11864 KB |
Output is correct |
27 |
Correct |
6 ms |
21848 KB |
Output is correct |
28 |
Incorrect |
6 ms |
13400 KB |
Output isn't correct |
29 |
Incorrect |
9 ms |
22872 KB |
Output isn't correct |
30 |
Incorrect |
10 ms |
22104 KB |
Output isn't correct |
31 |
Incorrect |
8 ms |
15704 KB |
Output isn't correct |
32 |
Incorrect |
9 ms |
21596 KB |
Output isn't correct |
33 |
Incorrect |
11 ms |
23640 KB |
Output isn't correct |
34 |
Incorrect |
5 ms |
13404 KB |
Output isn't correct |
35 |
Incorrect |
9 ms |
15708 KB |
Output isn't correct |
36 |
Correct |
12 ms |
30040 KB |
Output is correct |
37 |
Incorrect |
2 ms |
10840 KB |
Output isn't correct |
38 |
Correct |
261 ms |
129624 KB |
Output is correct |
39 |
Incorrect |
2 ms |
10840 KB |
Output isn't correct |
40 |
Incorrect |
38 ms |
51292 KB |
Output isn't correct |
41 |
Incorrect |
1 ms |
10844 KB |
Output isn't correct |
42 |
Incorrect |
2 ms |
11868 KB |
Output isn't correct |
43 |
Correct |
243 ms |
125776 KB |
Output is correct |
44 |
Incorrect |
12 ms |
29828 KB |
Output isn't correct |
45 |
Incorrect |
243 ms |
127824 KB |
Output isn't correct |
46 |
Correct |
246 ms |
129360 KB |
Output is correct |
47 |
Incorrect |
249 ms |
128044 KB |
Output isn't correct |
48 |
Incorrect |
254 ms |
129360 KB |
Output isn't correct |
49 |
Correct |
252 ms |
129512 KB |
Output is correct |
50 |
Incorrect |
247 ms |
129436 KB |
Output isn't correct |
51 |
Incorrect |
256 ms |
129360 KB |
Output isn't correct |
52 |
Incorrect |
243 ms |
129360 KB |
Output isn't correct |
53 |
Incorrect |
253 ms |
129056 KB |
Output isn't correct |
54 |
Incorrect |
242 ms |
115280 KB |
Output isn't correct |
55 |
Incorrect |
236 ms |
115024 KB |
Output isn't correct |
56 |
Correct |
247 ms |
129460 KB |
Output is correct |
57 |
Incorrect |
230 ms |
105040 KB |
Output isn't correct |
58 |
Incorrect |
245 ms |
115536 KB |
Output isn't correct |
59 |
Incorrect |
231 ms |
110928 KB |
Output isn't correct |
60 |
Correct |
240 ms |
121784 KB |
Output is correct |
61 |
Correct |
247 ms |
129620 KB |
Output is correct |
62 |
Correct |
251 ms |
129592 KB |
Output is correct |
63 |
Correct |
249 ms |
129616 KB |
Output is correct |
64 |
Correct |
241 ms |
116312 KB |
Output is correct |
65 |
Incorrect |
247 ms |
128848 KB |
Output isn't correct |
66 |
Incorrect |
256 ms |
127412 KB |
Output isn't correct |
67 |
Incorrect |
246 ms |
129472 KB |
Output isn't correct |
68 |
Incorrect |
246 ms |
129812 KB |
Output isn't correct |
69 |
Incorrect |
234 ms |
104272 KB |
Output isn't correct |
70 |
Incorrect |
151 ms |
58036 KB |
Output isn't correct |
71 |
Incorrect |
231 ms |
94932 KB |
Output isn't correct |
72 |
Incorrect |
238 ms |
102224 KB |
Output isn't correct |
73 |
Incorrect |
230 ms |
101780 KB |
Output isn't correct |
74 |
Incorrect |
248 ms |
108056 KB |
Output isn't correct |
75 |
Incorrect |
244 ms |
113256 KB |
Output isn't correct |
76 |
Incorrect |
238 ms |
115024 KB |
Output isn't correct |
77 |
Incorrect |
235 ms |
115348 KB |
Output isn't correct |
78 |
Incorrect |
244 ms |
116124 KB |
Output isn't correct |
79 |
Incorrect |
218 ms |
54868 KB |
Output isn't correct |
80 |
Incorrect |
231 ms |
56752 KB |
Output isn't correct |
81 |
Incorrect |
217 ms |
58704 KB |
Output isn't correct |
82 |
Incorrect |
242 ms |
119516 KB |
Output isn't correct |
83 |
Incorrect |
236 ms |
120144 KB |
Output isn't correct |
84 |
Incorrect |
218 ms |
38420 KB |
Output isn't correct |
85 |
Incorrect |
237 ms |
120656 KB |
Output isn't correct |
86 |
Incorrect |
250 ms |
128848 KB |
Output isn't correct |
87 |
Incorrect |
236 ms |
119632 KB |
Output isn't correct |
88 |
Incorrect |
248 ms |
118104 KB |
Output isn't correct |
89 |
Incorrect |
245 ms |
125264 KB |
Output isn't correct |
90 |
Incorrect |
156 ms |
99620 KB |
Output isn't correct |
91 |
Incorrect |
248 ms |
122036 KB |
Output isn't correct |
92 |
Incorrect |
239 ms |
120912 KB |
Output isn't correct |
93 |
Incorrect |
249 ms |
128336 KB |
Output isn't correct |
94 |
Incorrect |
242 ms |
123984 KB |
Output isn't correct |
95 |
Incorrect |
253 ms |
119736 KB |
Output isn't correct |
96 |
Incorrect |
237 ms |
119836 KB |
Output isn't correct |
97 |
Incorrect |
252 ms |
128796 KB |
Output isn't correct |
98 |
Incorrect |
235 ms |
118332 KB |
Output isn't correct |
99 |
Incorrect |
241 ms |
123472 KB |
Output isn't correct |
100 |
Incorrect |
249 ms |
128036 KB |
Output isn't correct |