#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <bitset>
#include <vector>
typedef long long llong;
const int MAXN = 2500 + 10;
int n, m;
int l[MAXN][MAXN];
int r[MAXN][MAXN];
int u[MAXN][MAXN];
int d[MAXN][MAXN];
char s[MAXN][MAXN];
void solve()
{
for (int i = 1 ; i <= n ; ++i)
{
for (int j = 1 ; j <= m ; ++j)
{
if (s[i][j] == '0')
{
l[i][j] = u[i][j] = 0;
} else
{
l[i][j] = l[i][j - 1] + 1;
u[i][j] = u[i - 1][j] + 1;
}
}
}
for (int i = n ; i >= 1 ; --i)
{
for (int j = m ; j >= 1 ; --j)
{
if (s[i][j] == '0')
{
r[i][j] = d[i][j] = 0;
} else
{
r[i][j] = r[i][j + 1] + 1;
d[i][j] = d[i + 1][j] + 1;
}
}
}
int maxLR = m, maxUD = n;
for (int i = 1 ; i <= n ; ++i)
{
for (int j = 1 ; j <= m ; ++j)
{
if (s[i][j] == '0') continue;
maxLR = std::min(maxLR, l[i][j] + r[i][j] - 1);
maxUD = std::min(maxUD, u[i][j] + d[i][j] - 1);
}
}
std::cout << maxLR * maxUD << '\n';
}
void input()
{
std::cin >> n >> m;
for (int i = 1 ; i <= n ; ++i)
{
std::cin >> s[i] + 1;
}
}
void fastIOI()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIOI();
input();
solve();
return 0;
}
Compilation message
bomb.cpp: In function 'void input()':
bomb.cpp:69:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
69 | std::cin >> s[i] + 1;
| ~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8652 KB |
Output is correct |
2 |
Correct |
2 ms |
10844 KB |
Output is correct |
3 |
Correct |
22 ms |
74844 KB |
Output is correct |
4 |
Correct |
15 ms |
74844 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Incorrect |
2 ms |
12892 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
12892 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
12636 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
12892 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
10844 KB |
Output isn't correct |
13 |
Correct |
2 ms |
12632 KB |
Output is correct |
14 |
Correct |
2 ms |
10844 KB |
Output is correct |
15 |
Incorrect |
2 ms |
12904 KB |
Output isn't correct |
16 |
Correct |
1 ms |
6748 KB |
Output is correct |
17 |
Correct |
2 ms |
14940 KB |
Output is correct |
18 |
Incorrect |
2 ms |
12892 KB |
Output isn't correct |
19 |
Incorrect |
2 ms |
13404 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
13404 KB |
Output isn't correct |
21 |
Incorrect |
2 ms |
17000 KB |
Output isn't correct |
22 |
Incorrect |
2 ms |
19036 KB |
Output isn't correct |
23 |
Incorrect |
2 ms |
13404 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
13148 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
13404 KB |
Output isn't correct |
26 |
Correct |
2 ms |
8028 KB |
Output is correct |
27 |
Correct |
4 ms |
14168 KB |
Output is correct |
28 |
Incorrect |
3 ms |
23388 KB |
Output isn't correct |
29 |
Incorrect |
4 ms |
25180 KB |
Output isn't correct |
30 |
Incorrect |
5 ms |
28796 KB |
Output isn't correct |
31 |
Incorrect |
4 ms |
22636 KB |
Output isn't correct |
32 |
Incorrect |
4 ms |
22364 KB |
Output isn't correct |
33 |
Incorrect |
5 ms |
30812 KB |
Output isn't correct |
34 |
Incorrect |
4 ms |
27228 KB |
Output isn't correct |
35 |
Incorrect |
5 ms |
30812 KB |
Output isn't correct |
36 |
Correct |
6 ms |
22364 KB |
Output is correct |
37 |
Incorrect |
3 ms |
16732 KB |
Output isn't correct |
38 |
Correct |
64 ms |
110952 KB |
Output is correct |
39 |
Incorrect |
2 ms |
16988 KB |
Output isn't correct |
40 |
Incorrect |
14 ms |
38592 KB |
Output isn't correct |
41 |
Incorrect |
2 ms |
16732 KB |
Output isn't correct |
42 |
Incorrect |
2 ms |
16988 KB |
Output isn't correct |
43 |
Correct |
50 ms |
111188 KB |
Output is correct |
44 |
Incorrect |
6 ms |
32840 KB |
Output isn't correct |
45 |
Incorrect |
49 ms |
111184 KB |
Output isn't correct |
46 |
Correct |
53 ms |
110936 KB |
Output is correct |
47 |
Incorrect |
51 ms |
111188 KB |
Output isn't correct |
48 |
Incorrect |
49 ms |
111240 KB |
Output isn't correct |
49 |
Correct |
58 ms |
111000 KB |
Output is correct |
50 |
Incorrect |
49 ms |
111256 KB |
Output isn't correct |
51 |
Incorrect |
49 ms |
111164 KB |
Output isn't correct |
52 |
Incorrect |
49 ms |
111208 KB |
Output isn't correct |
53 |
Incorrect |
47 ms |
111208 KB |
Output isn't correct |
54 |
Incorrect |
42 ms |
111188 KB |
Output isn't correct |
55 |
Incorrect |
43 ms |
111172 KB |
Output isn't correct |
56 |
Correct |
53 ms |
110944 KB |
Output is correct |
57 |
Incorrect |
41 ms |
111224 KB |
Output isn't correct |
58 |
Incorrect |
41 ms |
111184 KB |
Output isn't correct |
59 |
Incorrect |
40 ms |
111260 KB |
Output isn't correct |
60 |
Correct |
48 ms |
110932 KB |
Output is correct |
61 |
Correct |
58 ms |
110928 KB |
Output is correct |
62 |
Correct |
58 ms |
110932 KB |
Output is correct |
63 |
Correct |
57 ms |
110912 KB |
Output is correct |
64 |
Correct |
42 ms |
110932 KB |
Output is correct |
65 |
Incorrect |
47 ms |
111188 KB |
Output isn't correct |
66 |
Incorrect |
48 ms |
111184 KB |
Output isn't correct |
67 |
Incorrect |
49 ms |
111196 KB |
Output isn't correct |
68 |
Incorrect |
56 ms |
111088 KB |
Output isn't correct |
69 |
Incorrect |
42 ms |
111192 KB |
Output isn't correct |
70 |
Incorrect |
27 ms |
95040 KB |
Output isn't correct |
71 |
Incorrect |
40 ms |
111132 KB |
Output isn't correct |
72 |
Incorrect |
48 ms |
110932 KB |
Output isn't correct |
73 |
Incorrect |
44 ms |
111192 KB |
Output isn't correct |
74 |
Incorrect |
42 ms |
110936 KB |
Output isn't correct |
75 |
Incorrect |
42 ms |
110844 KB |
Output isn't correct |
76 |
Incorrect |
42 ms |
110936 KB |
Output isn't correct |
77 |
Incorrect |
44 ms |
110928 KB |
Output isn't correct |
78 |
Incorrect |
46 ms |
110932 KB |
Output isn't correct |
79 |
Incorrect |
33 ms |
110944 KB |
Output isn't correct |
80 |
Incorrect |
35 ms |
111188 KB |
Output isn't correct |
81 |
Incorrect |
35 ms |
110820 KB |
Output isn't correct |
82 |
Incorrect |
44 ms |
111024 KB |
Output isn't correct |
83 |
Incorrect |
43 ms |
110932 KB |
Output isn't correct |
84 |
Incorrect |
33 ms |
110936 KB |
Output isn't correct |
85 |
Incorrect |
44 ms |
110928 KB |
Output isn't correct |
86 |
Incorrect |
58 ms |
110836 KB |
Output isn't correct |
87 |
Incorrect |
43 ms |
110912 KB |
Output isn't correct |
88 |
Incorrect |
43 ms |
110928 KB |
Output isn't correct |
89 |
Incorrect |
51 ms |
111064 KB |
Output isn't correct |
90 |
Incorrect |
30 ms |
92884 KB |
Output isn't correct |
91 |
Incorrect |
45 ms |
111060 KB |
Output isn't correct |
92 |
Incorrect |
48 ms |
110968 KB |
Output isn't correct |
93 |
Incorrect |
57 ms |
110932 KB |
Output isn't correct |
94 |
Incorrect |
47 ms |
110956 KB |
Output isn't correct |
95 |
Incorrect |
45 ms |
110928 KB |
Output isn't correct |
96 |
Incorrect |
43 ms |
110820 KB |
Output isn't correct |
97 |
Incorrect |
58 ms |
110824 KB |
Output isn't correct |
98 |
Incorrect |
44 ms |
110960 KB |
Output isn't correct |
99 |
Incorrect |
54 ms |
110928 KB |
Output isn't correct |
100 |
Incorrect |
55 ms |
111024 KB |
Output isn't correct |