# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
94304 |
2019-01-17T12:35:22 Z |
Kastanda |
Bomb (IZhO17_bomb) |
C++11 |
|
275 ms |
57456 KB |
#include<bits/stdc++.h>
using namespace std;
const int N = 2505;
int n, m, Mnx, Mny, R[N], up[N][N], dn[N][N];
int qu[N], F[N];
char A[N][N];
inline int Calc(int lenx)
{
if (lenx > Mnx)
return 0;
int Mn = n;
for (int i = 1; i <= n; i++)
{
int l = 0, r = 0;
for (int j = 1; j <= m; j++)
{
while (r - l && dn[i][j] <= dn[i][qu[r-1]])
r --;
qu[r ++] = j;
if (qu[l] <= j - lenx)
l ++;
F[j - lenx + 1] = dn[i][qu[l]] - 1;
}
l = r = 0;
for (int j = 1; j <= m; j++)
{
while (r - l && up[i][j] >= up[i][qu[r-1]])
r --;
qu[r ++] = j;
if (qu[l] <= j - lenx)
l ++;
F[j - lenx + 1] -= up[i][qu[l]];
}
l = r = 0;
for (int j = 1; j <= m; j++)
{
if (j + lenx - 1 <= m)
{
F[j] = max(F[j], 0);
while (r - l && F[j] >= F[qu[r-1]])
r --;
qu[r ++] = j;
}
while (qu[l] <= j - lenx)
l ++;
if (A[i][j] == '1')
Mn = min(Mn, F[qu[l]]);
}
}
return (Mn);
}
inline void Init()
{
Mnx = m; Mny = n;
for (int i = 1; i <= n; i++)
{
int last = 0;
for (int j = 1; j <= m; j++)
if (A[i][j] == '0')
{
if (last != j - 1)
Mnx = min(Mnx, j - last - 1);
last = j;
}
if (last != m)
Mnx = min(Mnx, m - last);
}
for (int i = 1; i <= m; i++)
{
int last = 0;
for (int j = 1; j <= n; j++)
if (A[j][i] == '0')
{
if (last != j - 1)
Mny = min(Mny, j - last - 1);
last = j;
}
if (last != n)
Mny = min(Mny, n - last);
}
}
void Solve(int l = 1, int r = Mnx)
{
if (r - l + 1 <= 2)
return ;
if (R[l] == R[r])
{
for (int i = l + 1; i < r; i++)
R[i] = R[l];
return ;
}
int md = (l + r) >> 1;
R[md] = Calc(md);
Solve(l, md);
Solve(md, r);
}
int main()
{
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%s", &A[i][1]);
Init();
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
up[i][j] = i - 1;
if (A[i - 1][j] == '1')
up[i][j] = up[i - 1][j];
}
for (int i = n; i; i--)
for (int j = 1; j <= m; j++)
{
dn[i][j] = i + 1;
if (A[i + 1][j] == '1')
dn[i][j] = dn[i + 1][j];
if (A[i][j] == '0')
dn[i][j] = 0, up[i][j] = n + 1;
}
R[1] = Calc(1);
R[Mnx] = Calc(Mnx);
int Mx_s = 0;
for (int i = 1; i <= Mnx; i++)
Mx_s = max(Mx_s, i * R[i]);
return !printf("%d", Mx_s);
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:102:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
~~~~~^~~~~~~~~~~~~~~~
bomb.cpp:104:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", &A[i][1]);
~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
21 ms |
26616 KB |
Output is correct |
4 |
Correct |
21 ms |
26616 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
1 ms |
376 KB |
Output is correct |
8 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
16 |
Correct |
2 ms |
508 KB |
Output is correct |
17 |
Correct |
3 ms |
1016 KB |
Output is correct |
18 |
Incorrect |
2 ms |
1144 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
1400 KB |
Output isn't correct |
20 |
Incorrect |
3 ms |
1400 KB |
Output isn't correct |
21 |
Incorrect |
2 ms |
888 KB |
Output isn't correct |
22 |
Incorrect |
3 ms |
1144 KB |
Output isn't correct |
23 |
Incorrect |
7 ms |
1528 KB |
Output isn't correct |
24 |
Incorrect |
3 ms |
1276 KB |
Output isn't correct |
25 |
Incorrect |
3 ms |
1528 KB |
Output isn't correct |
26 |
Correct |
3 ms |
1528 KB |
Output is correct |
27 |
Correct |
7 ms |
4088 KB |
Output is correct |
28 |
Incorrect |
8 ms |
4216 KB |
Output isn't correct |
29 |
Incorrect |
10 ms |
5496 KB |
Output isn't correct |
30 |
Incorrect |
12 ms |
6392 KB |
Output isn't correct |
31 |
Incorrect |
10 ms |
5112 KB |
Output isn't correct |
32 |
Incorrect |
10 ms |
5880 KB |
Output isn't correct |
33 |
Incorrect |
12 ms |
6776 KB |
Output isn't correct |
34 |
Incorrect |
7 ms |
4756 KB |
Output isn't correct |
35 |
Incorrect |
11 ms |
6776 KB |
Output isn't correct |
36 |
Correct |
12 ms |
6648 KB |
Output is correct |
37 |
Correct |
2 ms |
504 KB |
Output is correct |
38 |
Correct |
205 ms |
57232 KB |
Output is correct |
39 |
Correct |
2 ms |
504 KB |
Output is correct |
40 |
Correct |
73 ms |
16120 KB |
Output is correct |
41 |
Incorrect |
2 ms |
636 KB |
Output isn't correct |
42 |
Incorrect |
3 ms |
1400 KB |
Output isn't correct |
43 |
Correct |
249 ms |
57224 KB |
Output is correct |
44 |
Incorrect |
11 ms |
6776 KB |
Output isn't correct |
45 |
Incorrect |
231 ms |
57356 KB |
Output isn't correct |
46 |
Correct |
275 ms |
57176 KB |
Output is correct |
47 |
Incorrect |
260 ms |
57340 KB |
Output isn't correct |
48 |
Incorrect |
247 ms |
57208 KB |
Output isn't correct |
49 |
Correct |
258 ms |
57208 KB |
Output is correct |
50 |
Incorrect |
246 ms |
57276 KB |
Output isn't correct |
51 |
Incorrect |
232 ms |
57340 KB |
Output isn't correct |
52 |
Incorrect |
246 ms |
57236 KB |
Output isn't correct |
53 |
Incorrect |
243 ms |
57456 KB |
Output isn't correct |
54 |
Incorrect |
252 ms |
57336 KB |
Output isn't correct |
55 |
Incorrect |
242 ms |
57208 KB |
Output isn't correct |
56 |
Correct |
275 ms |
57336 KB |
Output is correct |
57 |
Incorrect |
241 ms |
57208 KB |
Output isn't correct |
58 |
Incorrect |
226 ms |
57208 KB |
Output isn't correct |
59 |
Incorrect |
232 ms |
57208 KB |
Output isn't correct |
60 |
Correct |
218 ms |
57356 KB |
Output is correct |
61 |
Correct |
253 ms |
57272 KB |
Output is correct |
62 |
Correct |
222 ms |
57208 KB |
Output is correct |
63 |
Correct |
223 ms |
57244 KB |
Output is correct |
64 |
Correct |
235 ms |
57336 KB |
Output is correct |
65 |
Incorrect |
250 ms |
57308 KB |
Output isn't correct |
66 |
Incorrect |
239 ms |
57212 KB |
Output isn't correct |
67 |
Incorrect |
241 ms |
57184 KB |
Output isn't correct |
68 |
Incorrect |
259 ms |
57208 KB |
Output isn't correct |
69 |
Incorrect |
241 ms |
57208 KB |
Output isn't correct |
70 |
Incorrect |
162 ms |
46200 KB |
Output isn't correct |
71 |
Incorrect |
234 ms |
57308 KB |
Output isn't correct |
72 |
Incorrect |
227 ms |
57260 KB |
Output isn't correct |
73 |
Incorrect |
228 ms |
57080 KB |
Output isn't correct |
74 |
Incorrect |
224 ms |
57008 KB |
Output isn't correct |
75 |
Incorrect |
249 ms |
56872 KB |
Output isn't correct |
76 |
Incorrect |
236 ms |
57080 KB |
Output isn't correct |
77 |
Incorrect |
234 ms |
57028 KB |
Output isn't correct |
78 |
Incorrect |
221 ms |
56952 KB |
Output isn't correct |
79 |
Incorrect |
226 ms |
56952 KB |
Output isn't correct |
80 |
Incorrect |
223 ms |
56928 KB |
Output isn't correct |
81 |
Incorrect |
227 ms |
56696 KB |
Output isn't correct |
82 |
Incorrect |
225 ms |
56824 KB |
Output isn't correct |
83 |
Incorrect |
222 ms |
56924 KB |
Output isn't correct |
84 |
Incorrect |
240 ms |
56668 KB |
Output isn't correct |
85 |
Incorrect |
240 ms |
56824 KB |
Output isn't correct |
86 |
Incorrect |
242 ms |
56952 KB |
Output isn't correct |
87 |
Correct |
255 ms |
56952 KB |
Output is correct |
88 |
Incorrect |
243 ms |
57080 KB |
Output isn't correct |
89 |
Incorrect |
241 ms |
56892 KB |
Output isn't correct |
90 |
Incorrect |
155 ms |
45688 KB |
Output isn't correct |
91 |
Incorrect |
239 ms |
56824 KB |
Output isn't correct |
92 |
Incorrect |
239 ms |
56812 KB |
Output isn't correct |
93 |
Incorrect |
222 ms |
56768 KB |
Output isn't correct |
94 |
Incorrect |
233 ms |
56700 KB |
Output isn't correct |
95 |
Incorrect |
248 ms |
56700 KB |
Output isn't correct |
96 |
Incorrect |
248 ms |
56748 KB |
Output isn't correct |
97 |
Incorrect |
221 ms |
56828 KB |
Output isn't correct |
98 |
Incorrect |
243 ms |
56952 KB |
Output isn't correct |
99 |
Incorrect |
246 ms |
56696 KB |
Output isn't correct |
100 |
Incorrect |
240 ms |
56568 KB |
Output isn't correct |