# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
706330 |
2023-03-06T09:34:20 Z |
KiriLL1ca |
Bomb (IZhO17_bomb) |
C++17 |
|
413 ms |
58660 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define endl '\n'
#define sz(x) (int)((x).size())
#define vec vector
#define pw(x) (1ll << x)
using namespace std;
using namespace __gnu_pbds;
template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int inf = 1e9 + 17;
inline void solve () {
int n, m; cin >> n >> m;
vec <string> a (n);
for (auto &i : a) cin >> i;
vec <int> mx (m + 2, inf);
for (int iter = 0; iter < 2; ++iter) {
vec <vec <int>> p (n, vec <int> (m)), s (n, vec <int> (m));
for (int j = 0; j < m; ++j) {
p[0][j] = (a[0][j] == '1');
for (int i = 1; i < n; ++i) {
if (a[i][j] == '1') p[i][j] = p[i - 1][j] + 1;
}
s[n - 1][j] = (a[n - 1][j] == '1');
for (int i = n - 2; ~i; --i) {
if (a[i][j] == '1') s[i][j] = s[i + 1][j] + 1;
}
}
for (int i = 0; i < n; ++i) {
for (int l = 0, r = 0; r < m; ) {
while (r < m && a[i][r] == '1') ++r;
if (l == r) {
++l, ++r;
continue;
}
int mn_down = inf, mn_up = inf;
for (int q = l; q < r; ++q) {
umin(mn_up, p[i][q]);
umin(mn_down, s[i][q]);
umin(mx[q - l + 1], mn_down + mn_up - 1);
}
umin(mx[r - l + 1], 0);
l = r;
}
}
for (auto &i : a) reverse(all(i));
}
int ans = 0;
for (int i = 1; i <= m; ++i) {
umin(mx[i], mx[i - 1]);
umax(ans, mx[i] * i);
}
cout << ans << endl;
}
signed main () {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif// LOCAL
int t = 1; //cin >> t;
while (t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
276 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
580 KB |
Output is correct |
4 |
Correct |
2 ms |
596 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
316 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
320 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
324 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
328 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
27 |
Incorrect |
3 ms |
1108 KB |
Output isn't correct |
28 |
Correct |
4 ms |
1372 KB |
Output is correct |
29 |
Correct |
4 ms |
1508 KB |
Output is correct |
30 |
Correct |
6 ms |
2172 KB |
Output is correct |
31 |
Correct |
6 ms |
1948 KB |
Output is correct |
32 |
Correct |
5 ms |
1892 KB |
Output is correct |
33 |
Correct |
4 ms |
2360 KB |
Output is correct |
34 |
Correct |
2 ms |
1168 KB |
Output is correct |
35 |
Correct |
4 ms |
2312 KB |
Output is correct |
36 |
Incorrect |
5 ms |
2312 KB |
Output isn't correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Correct |
388 ms |
58592 KB |
Output is correct |
39 |
Correct |
1 ms |
320 KB |
Output is correct |
40 |
Correct |
33 ms |
8020 KB |
Output is correct |
41 |
Correct |
1 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
340 KB |
Output is correct |
43 |
Correct |
327 ms |
58612 KB |
Output is correct |
44 |
Correct |
7 ms |
2356 KB |
Output is correct |
45 |
Correct |
344 ms |
58592 KB |
Output is correct |
46 |
Correct |
319 ms |
58604 KB |
Output is correct |
47 |
Correct |
357 ms |
58488 KB |
Output is correct |
48 |
Correct |
315 ms |
58468 KB |
Output is correct |
49 |
Incorrect |
405 ms |
58660 KB |
Output isn't correct |
50 |
Correct |
327 ms |
58472 KB |
Output is correct |
51 |
Correct |
307 ms |
58516 KB |
Output is correct |
52 |
Correct |
313 ms |
58500 KB |
Output is correct |
53 |
Correct |
314 ms |
58484 KB |
Output is correct |
54 |
Correct |
245 ms |
58208 KB |
Output is correct |
55 |
Correct |
235 ms |
58208 KB |
Output is correct |
56 |
Correct |
413 ms |
58084 KB |
Output is correct |
57 |
Correct |
226 ms |
57828 KB |
Output is correct |
58 |
Correct |
233 ms |
57492 KB |
Output is correct |
59 |
Correct |
212 ms |
57540 KB |
Output is correct |
60 |
Incorrect |
269 ms |
57124 KB |
Output isn't correct |
61 |
Incorrect |
393 ms |
56724 KB |
Output isn't correct |
62 |
Incorrect |
379 ms |
56552 KB |
Output isn't correct |
63 |
Incorrect |
400 ms |
56452 KB |
Output isn't correct |
64 |
Incorrect |
217 ms |
56504 KB |
Output isn't correct |
65 |
Correct |
294 ms |
56424 KB |
Output is correct |
66 |
Correct |
277 ms |
56492 KB |
Output is correct |
67 |
Correct |
298 ms |
56420 KB |
Output is correct |
68 |
Correct |
323 ms |
56424 KB |
Output is correct |
69 |
Correct |
211 ms |
56424 KB |
Output is correct |
70 |
Correct |
95 ms |
36320 KB |
Output is correct |
71 |
Correct |
186 ms |
56452 KB |
Output is correct |
72 |
Correct |
216 ms |
56424 KB |
Output is correct |
73 |
Correct |
239 ms |
56440 KB |
Output is correct |
74 |
Correct |
215 ms |
56396 KB |
Output is correct |
75 |
Correct |
234 ms |
56468 KB |
Output is correct |
76 |
Correct |
234 ms |
56420 KB |
Output is correct |
77 |
Correct |
223 ms |
56492 KB |
Output is correct |
78 |
Correct |
225 ms |
56420 KB |
Output is correct |
79 |
Correct |
142 ms |
56460 KB |
Output is correct |
80 |
Correct |
135 ms |
56424 KB |
Output is correct |
81 |
Correct |
150 ms |
56492 KB |
Output is correct |
82 |
Correct |
231 ms |
56552 KB |
Output is correct |
83 |
Correct |
235 ms |
56596 KB |
Output is correct |
84 |
Correct |
149 ms |
56548 KB |
Output is correct |
85 |
Correct |
211 ms |
56440 KB |
Output is correct |
86 |
Correct |
348 ms |
56484 KB |
Output is correct |
87 |
Correct |
216 ms |
56184 KB |
Output is correct |
88 |
Correct |
228 ms |
56172 KB |
Output is correct |
89 |
Correct |
269 ms |
56192 KB |
Output is correct |
90 |
Correct |
129 ms |
36052 KB |
Output is correct |
91 |
Correct |
232 ms |
56288 KB |
Output is correct |
92 |
Correct |
275 ms |
56216 KB |
Output is correct |
93 |
Correct |
345 ms |
56300 KB |
Output is correct |
94 |
Correct |
297 ms |
56164 KB |
Output is correct |
95 |
Correct |
236 ms |
56140 KB |
Output is correct |
96 |
Correct |
232 ms |
56164 KB |
Output is correct |
97 |
Correct |
367 ms |
56164 KB |
Output is correct |
98 |
Correct |
225 ms |
56164 KB |
Output is correct |
99 |
Correct |
255 ms |
56168 KB |
Output is correct |
100 |
Correct |
381 ms |
56148 KB |
Output is correct |