# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
94312 |
2019-01-17T12:59:40 Z |
Kastanda |
Bomb (IZhO17_bomb) |
C++11 |
|
451 ms |
26616 KB |
#include<bits/stdc++.h>
using namespace std;
const int N = 2505;
int n, m, Mnx, 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;
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);
}
}
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();
if (1LL * n * m * m >= 1000 * 1000 * 1000)
return !printf("No thanks.");
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);
Solve(1, Mnx);
set < int > S;
for (int i = 1; i <= Mnx; i++)
S.insert(R[i]);
if ((int)S.size() >= 50)
assert(0);
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:87: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:89: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 |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
21 ms |
26616 KB |
Output is correct |
4 |
Correct |
21 ms |
26548 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Correct |
2 ms |
504 KB |
Output is 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 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
2 ms |
504 KB |
Output is correct |
17 |
Correct |
2 ms |
1016 KB |
Output is correct |
18 |
Correct |
3 ms |
1144 KB |
Output is correct |
19 |
Correct |
3 ms |
1400 KB |
Output is correct |
20 |
Correct |
3 ms |
1400 KB |
Output is correct |
21 |
Correct |
3 ms |
1016 KB |
Output is correct |
22 |
Correct |
3 ms |
1272 KB |
Output is correct |
23 |
Correct |
3 ms |
1400 KB |
Output is correct |
24 |
Correct |
3 ms |
1272 KB |
Output is correct |
25 |
Correct |
3 ms |
1400 KB |
Output is correct |
26 |
Correct |
3 ms |
1528 KB |
Output is correct |
27 |
Correct |
7 ms |
4088 KB |
Output is correct |
28 |
Correct |
14 ms |
4216 KB |
Output is correct |
29 |
Correct |
86 ms |
5368 KB |
Output is correct |
30 |
Correct |
31 ms |
6456 KB |
Output is correct |
31 |
Correct |
25 ms |
5112 KB |
Output is correct |
32 |
Correct |
23 ms |
5880 KB |
Output is correct |
33 |
Correct |
41 ms |
6776 KB |
Output is correct |
34 |
Correct |
15 ms |
4728 KB |
Output is correct |
35 |
Correct |
38 ms |
6776 KB |
Output is correct |
36 |
Correct |
12 ms |
6776 KB |
Output is correct |
37 |
Correct |
2 ms |
632 KB |
Output is correct |
38 |
Incorrect |
27 ms |
9464 KB |
Output isn't correct |
39 |
Correct |
2 ms |
504 KB |
Output is correct |
40 |
Correct |
339 ms |
16196 KB |
Output is correct |
41 |
Correct |
2 ms |
504 KB |
Output is correct |
42 |
Correct |
7 ms |
1400 KB |
Output is correct |
43 |
Incorrect |
28 ms |
9464 KB |
Output isn't correct |
44 |
Runtime error |
451 ms |
13276 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
45 |
Incorrect |
30 ms |
9464 KB |
Output isn't correct |
46 |
Incorrect |
32 ms |
9592 KB |
Output isn't correct |
47 |
Incorrect |
29 ms |
9468 KB |
Output isn't correct |
48 |
Incorrect |
30 ms |
9464 KB |
Output isn't correct |
49 |
Incorrect |
27 ms |
9464 KB |
Output isn't correct |
50 |
Incorrect |
28 ms |
9436 KB |
Output isn't correct |
51 |
Incorrect |
29 ms |
9464 KB |
Output isn't correct |
52 |
Incorrect |
28 ms |
9464 KB |
Output isn't correct |
53 |
Incorrect |
30 ms |
9536 KB |
Output isn't correct |
54 |
Incorrect |
45 ms |
9508 KB |
Output isn't correct |
55 |
Incorrect |
29 ms |
9464 KB |
Output isn't correct |
56 |
Incorrect |
19 ms |
9592 KB |
Output isn't correct |
57 |
Incorrect |
30 ms |
9468 KB |
Output isn't correct |
58 |
Incorrect |
29 ms |
10104 KB |
Output isn't correct |
59 |
Incorrect |
29 ms |
10104 KB |
Output isn't correct |
60 |
Incorrect |
30 ms |
10104 KB |
Output isn't correct |
61 |
Incorrect |
27 ms |
10104 KB |
Output isn't correct |
62 |
Incorrect |
26 ms |
10104 KB |
Output isn't correct |
63 |
Incorrect |
27 ms |
9848 KB |
Output isn't correct |
64 |
Incorrect |
30 ms |
9832 KB |
Output isn't correct |
65 |
Incorrect |
29 ms |
9820 KB |
Output isn't correct |
66 |
Incorrect |
29 ms |
9888 KB |
Output isn't correct |
67 |
Incorrect |
30 ms |
9848 KB |
Output isn't correct |
68 |
Incorrect |
30 ms |
9884 KB |
Output isn't correct |
69 |
Incorrect |
30 ms |
9848 KB |
Output isn't correct |
70 |
Incorrect |
21 ms |
8056 KB |
Output isn't correct |
71 |
Incorrect |
32 ms |
9848 KB |
Output isn't correct |
72 |
Incorrect |
30 ms |
9976 KB |
Output isn't correct |
73 |
Incorrect |
31 ms |
9848 KB |
Output isn't correct |
74 |
Incorrect |
31 ms |
9592 KB |
Output isn't correct |
75 |
Incorrect |
30 ms |
9592 KB |
Output isn't correct |
76 |
Incorrect |
31 ms |
9592 KB |
Output isn't correct |
77 |
Incorrect |
31 ms |
9848 KB |
Output isn't correct |
78 |
Incorrect |
30 ms |
9848 KB |
Output isn't correct |
79 |
Incorrect |
32 ms |
9720 KB |
Output isn't correct |
80 |
Incorrect |
31 ms |
9464 KB |
Output isn't correct |
81 |
Incorrect |
32 ms |
9356 KB |
Output isn't correct |
82 |
Incorrect |
31 ms |
8776 KB |
Output isn't correct |
83 |
Incorrect |
30 ms |
8952 KB |
Output isn't correct |
84 |
Incorrect |
31 ms |
8824 KB |
Output isn't correct |
85 |
Incorrect |
31 ms |
8700 KB |
Output isn't correct |
86 |
Incorrect |
28 ms |
8696 KB |
Output isn't correct |
87 |
Incorrect |
31 ms |
8696 KB |
Output isn't correct |
88 |
Incorrect |
30 ms |
8696 KB |
Output isn't correct |
89 |
Incorrect |
29 ms |
8440 KB |
Output isn't correct |
90 |
Incorrect |
21 ms |
6520 KB |
Output isn't correct |
91 |
Incorrect |
29 ms |
7928 KB |
Output isn't correct |
92 |
Incorrect |
28 ms |
7928 KB |
Output isn't correct |
93 |
Incorrect |
28 ms |
7928 KB |
Output isn't correct |
94 |
Incorrect |
28 ms |
8056 KB |
Output isn't correct |
95 |
Incorrect |
29 ms |
7928 KB |
Output isn't correct |
96 |
Incorrect |
29 ms |
7964 KB |
Output isn't correct |
97 |
Incorrect |
28 ms |
7932 KB |
Output isn't correct |
98 |
Incorrect |
51 ms |
8056 KB |
Output isn't correct |
99 |
Incorrect |
29 ms |
7928 KB |
Output isn't correct |
100 |
Incorrect |
28 ms |
8056 KB |
Output isn't correct |