# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
400020 |
2021-05-07T06:59:46 Z |
syl123456 |
Bomb (IZhO17_bomb) |
C++17 |
|
539 ms |
74692 KB |
#include <bits/stdc++.h>
#define all(i) (i).begin(), (i).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl
using namespace std;
template<typename T1, typename T2>
ostream& operator << (ostream &i, pair<T1, T2> j) {
return i << j.first << ' ' << j.second;
}
template<typename T>
ostream& operator << (ostream &i, vector<T> j) {
i << '{' << j.size() << ':';
for (T ii : j) i << ' ' << ii;
return i << '}';
}
typedef long long ll;
typedef pair<int, int> pi;
int n, m, mxh, mxw;
vector<vector<int>> h, w;
vector<int> lim;
void check(vector<string> v) {
for (int i = 1; i <= n; ++i) {
pi pre(0, 0);
for (int j = 1; j <= m + 1; ++j) {
if (v[i - 1][j] == '0' && v[i][j - 1] == '0') {
pre = pi(j, min(mxh, h[i][j]));
continue;
}
if (h[i][j] >= pre.second) continue;
lim[h[i][j] + 1] = min(lim[h[i][j] + 1], j - pre.first);
pre.second = h[i][j];
}
}
}
int solve(vector<string> v) {
h.assign(n + 2, vector<int>(m + 2, 0));
w.assign(n + 2, vector<int>(m + 2, 0));
mxh = n, mxw = m;
for (int i = n; i; --i) for (int j = m; j; --j) if (v[i][j] == '1') {
h[i][j] = h[i + 1][j] + 1, w[i][j] = w[i][j + 1] + 1;
if (v[i - 1][j] == '0') mxh = min(mxh, h[i][j]);
if (v[i][j - 1] == '0') mxw = min(mxw, w[i][j]);
}
lim.assign(mxh + 2, mxw);
check(v);
for (int i = 1; i <= n; ++i) for (int _l = 1, _r = m; _l < _r; ++_l, --_r)
swap(h[i][_l], h[i][_r]), swap(v[i][_l], v[i][_r]);
check(v);
for (int i = 1; i <= m; ++i) for (int _l = 1, _r = n; _l < _r; ++_l, --_r)
swap(v[_l][i], v[_r][i]);
h.assign(n + 2, vector<int>(m + 2, 0));
for (int i = n; i; --i) for (int j = m; j; --j) if (v[i][j] == '1')
h[i][j] = h[i + 1][j] + 1;
check(v);
for (int i = 1; i <= n; ++i) for (int _l = 1, _r = m; _l < _r; ++_l, --_r)
swap(h[i][_l], h[i][_r]), swap(v[i][_l], v[i][_r]);
check(v);
int ans = 0;
for (int i = 1; i <= mxh; ++i) lim[i] = min(lim[i], lim[i - 1]), ans = max(ans, i * lim[i]);
return ans;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
vector<string> v(n + 2, string(m + 2, '0')), v1(m + 2, string(n + 2, '0'));
for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) cin >> v[i][j], v1[j][i] = v[i][j];
int ans = solve(v);
swap(n, m);
ans = min(ans, solve(v1));
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
716 KB |
Output is correct |
4 |
Correct |
2 ms |
716 KB |
Output is correct |
5 |
Correct |
2 ms |
844 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
2 ms |
460 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
460 KB |
Output is correct |
26 |
Correct |
2 ms |
460 KB |
Output is correct |
27 |
Correct |
7 ms |
1228 KB |
Output is correct |
28 |
Correct |
8 ms |
1996 KB |
Output is correct |
29 |
Correct |
11 ms |
1996 KB |
Output is correct |
30 |
Correct |
14 ms |
3164 KB |
Output is correct |
31 |
Correct |
11 ms |
2584 KB |
Output is correct |
32 |
Correct |
11 ms |
2268 KB |
Output is correct |
33 |
Correct |
15 ms |
2812 KB |
Output is correct |
34 |
Correct |
6 ms |
1388 KB |
Output is correct |
35 |
Correct |
15 ms |
2820 KB |
Output is correct |
36 |
Correct |
16 ms |
2824 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
490 ms |
74360 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Incorrect |
58 ms |
11876 KB |
Output isn't correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
2 ms |
460 KB |
Output is correct |
43 |
Correct |
483 ms |
74440 KB |
Output is correct |
44 |
Correct |
16 ms |
2820 KB |
Output is correct |
45 |
Correct |
497 ms |
74368 KB |
Output is correct |
46 |
Correct |
505 ms |
74356 KB |
Output is correct |
47 |
Correct |
517 ms |
74348 KB |
Output is correct |
48 |
Correct |
530 ms |
74360 KB |
Output is correct |
49 |
Correct |
517 ms |
74364 KB |
Output is correct |
50 |
Correct |
489 ms |
74340 KB |
Output is correct |
51 |
Correct |
505 ms |
74364 KB |
Output is correct |
52 |
Correct |
496 ms |
74368 KB |
Output is correct |
53 |
Correct |
480 ms |
74364 KB |
Output is correct |
54 |
Correct |
472 ms |
74424 KB |
Output is correct |
55 |
Correct |
468 ms |
74496 KB |
Output is correct |
56 |
Correct |
500 ms |
74380 KB |
Output is correct |
57 |
Correct |
467 ms |
74360 KB |
Output is correct |
58 |
Correct |
463 ms |
74692 KB |
Output is correct |
59 |
Correct |
472 ms |
74360 KB |
Output is correct |
60 |
Correct |
490 ms |
74428 KB |
Output is correct |
61 |
Correct |
506 ms |
74352 KB |
Output is correct |
62 |
Correct |
509 ms |
74464 KB |
Output is correct |
63 |
Correct |
507 ms |
74388 KB |
Output is correct |
64 |
Correct |
481 ms |
74364 KB |
Output is correct |
65 |
Correct |
488 ms |
74596 KB |
Output is correct |
66 |
Correct |
481 ms |
74504 KB |
Output is correct |
67 |
Correct |
489 ms |
74364 KB |
Output is correct |
68 |
Correct |
493 ms |
74516 KB |
Output is correct |
69 |
Correct |
463 ms |
74364 KB |
Output is correct |
70 |
Correct |
280 ms |
47964 KB |
Output is correct |
71 |
Correct |
463 ms |
74364 KB |
Output is correct |
72 |
Correct |
477 ms |
74484 KB |
Output is correct |
73 |
Correct |
478 ms |
74400 KB |
Output is correct |
74 |
Correct |
464 ms |
74356 KB |
Output is correct |
75 |
Correct |
474 ms |
74384 KB |
Output is correct |
76 |
Correct |
472 ms |
74356 KB |
Output is correct |
77 |
Correct |
469 ms |
74356 KB |
Output is correct |
78 |
Correct |
469 ms |
74388 KB |
Output is correct |
79 |
Correct |
440 ms |
74408 KB |
Output is correct |
80 |
Correct |
446 ms |
74416 KB |
Output is correct |
81 |
Correct |
447 ms |
74340 KB |
Output is correct |
82 |
Correct |
478 ms |
74372 KB |
Output is correct |
83 |
Correct |
468 ms |
74364 KB |
Output is correct |
84 |
Correct |
467 ms |
74348 KB |
Output is correct |
85 |
Correct |
469 ms |
74424 KB |
Output is correct |
86 |
Correct |
501 ms |
74364 KB |
Output is correct |
87 |
Correct |
471 ms |
74436 KB |
Output is correct |
88 |
Correct |
469 ms |
74424 KB |
Output is correct |
89 |
Correct |
476 ms |
74456 KB |
Output is correct |
90 |
Correct |
281 ms |
47836 KB |
Output is correct |
91 |
Correct |
472 ms |
74364 KB |
Output is correct |
92 |
Correct |
483 ms |
74416 KB |
Output is correct |
93 |
Correct |
505 ms |
74480 KB |
Output is correct |
94 |
Correct |
484 ms |
74448 KB |
Output is correct |
95 |
Correct |
474 ms |
74356 KB |
Output is correct |
96 |
Correct |
477 ms |
74420 KB |
Output is correct |
97 |
Correct |
507 ms |
74364 KB |
Output is correct |
98 |
Correct |
467 ms |
74436 KB |
Output is correct |
99 |
Correct |
506 ms |
74484 KB |
Output is correct |
100 |
Correct |
539 ms |
74368 KB |
Output is correct |