# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1030368 |
2024-07-22T03:45:54 Z |
caterpillow |
Bomb (IZhO17_bomb) |
C++17 |
|
114 ms |
1312 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define vt vector
#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, b) FOR(i, 0, b)
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define pb push_back
#define endl '\n'
#ifndef LOCAL
#define cerr if (0) std::cerr
#endif
/*
N^3: find max width for each given height
*/
int rs, cs;
vt<vt<bool>> grid;
vt<vt<int>> sfx;
int sum(int r1, int c1, int r2, int c2) {
return sfx[r1][c1] - sfx[r1][c2 + 1] - sfx[r2 + 1][c1] + sfx[r2 + 1][c2 + 1];
}
int mx(int h) {
cerr << "\nchecking " << h << endl;
// find longest run
vt<vt<bool>> mod(rs - h + 1, vt<bool>(cs));
F0R (r, rs - h + 1) {
F0R (c, cs) {
mod[r][c] = sum(r, c, r + h - 1, c) == h;
}
}
int mn = cs;
F0R (r, rs - h + 1) {
int streak = 0;
F0R (c, cs) {
if (mod[r][c]) streak++;
else if (streak) mn = min(mn, streak), streak = 0;
}
}
return mn;
}
main() {
cin.tie(0)->sync_with_stdio();
cin >> rs >> cs;
if (rs > 450 || cs > 450) return 0;
rs += 2, cs += 2;
grid.resize(rs, vt<bool>(cs));
sfx.resize(rs + 1, vt<int>(cs + 1));
FOR (r, 1, rs - 1) {
FOR (c, 1, cs - 1) {
char ch; cin >> ch;
grid[r][c] = sfx[r][c] = ch - '0';
}
}
ROF (r, 0, rs) ROF (c, 0, cs) sfx[r][c] += sfx[r][c + 1];
ROF (r, 0, rs) ROF (c, 0, cs) sfx[r][c] += sfx[r + 1][c];
// calculate maximum height
int mxh = rs;
F0R (c, cs) {
int streak = 0;
F0R (r, rs) {
if (grid[r][c]) streak++;
else if (streak) mxh = min(mxh, streak), streak = 0;
}
}
cerr << "maximum height " << mxh << endl;
int ans = 0;
FOR (h, 1, mxh + 1) {
ans = max(ans, h * mx(h));
}
cout << ans << endl;
}
Compilation message
bomb.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
56 | main() {
| ^~~~
bomb.cpp: In function 'int main()':
bomb.cpp:67:36: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
67 | grid[r][c] = sfx[r][c] = ch - '0';
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
600 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
26 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
27 |
Correct |
4 ms |
604 KB |
Output is correct |
28 |
Correct |
5 ms |
916 KB |
Output is correct |
29 |
Incorrect |
33 ms |
860 KB |
Output isn't correct |
30 |
Incorrect |
67 ms |
1112 KB |
Output isn't correct |
31 |
Incorrect |
37 ms |
1116 KB |
Output isn't correct |
32 |
Incorrect |
62 ms |
1112 KB |
Output isn't correct |
33 |
Incorrect |
81 ms |
1116 KB |
Output isn't correct |
34 |
Correct |
5 ms |
604 KB |
Output is correct |
35 |
Incorrect |
17 ms |
1308 KB |
Output isn't correct |
36 |
Incorrect |
37 ms |
1112 KB |
Output isn't correct |
37 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
38 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
39 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
40 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
42 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
43 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
44 |
Incorrect |
114 ms |
1312 KB |
Output isn't correct |
45 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
46 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
47 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
48 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
49 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
50 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
51 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
52 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
53 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
54 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
55 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
56 |
Incorrect |
0 ms |
380 KB |
Output isn't correct |
57 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
58 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
59 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
60 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
61 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
62 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
63 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
64 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
65 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
66 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
67 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
68 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
69 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
70 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
71 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
72 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
73 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
74 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
75 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
76 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
77 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
78 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
79 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
80 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
81 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
82 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
83 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
84 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
85 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
86 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
87 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
88 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
89 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
90 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
91 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
92 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
93 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
94 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
95 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
96 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
97 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
98 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
99 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
100 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |