# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
854632 |
2023-09-28T08:54:26 Z |
The_Samurai |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
31320 KB |
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int inf = 1e9, N = 1e6 + 5;
int main() {
cin.tie(0)->sync_with_stdio(false);
#ifdef sunnatov
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
// freopen("bomb.in", "r", stdin);
// freopen("bomb.out", "w", stdout);
#endif
int n, m;
cin >> n >> m;
vector<vector<char>> a(n + 1, vector<char>(m + 1));
vector<vector<int>> pref(n + 1, vector<int>(m + 1));
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) {
cin >> a[i][j];
pref[i][j] = pref[i][j - 1] + pref[i - 1][j] - pref[i - 1][j - 1] + (int) (a[i][j] == '1');
}
auto get_sum = [&](int x1, int y1, int x2, int y2) {
return pref[x2][y2] - pref[x2][y1 - 1] - pref[x1 - 1][y2] + pref[x1 - 1][y1 - 1];
};
auto get = [&](int h) {
int mn = m;
vector<int> last(m + 1, -inf);
for (int i = 1; i <= n; i++) {
int cnt = 0;
for (int j = 1; j <= m; j++) {
if (a[i][j] == '0') {
if (cnt > 0) mn = min(mn, cnt);
cnt = 0;
continue;
}
if (i + h - 1 > n or get_sum(i, j, i + h - 1, j) != h) {
if (i - last[j] >= h) return 0;
continue;
}
last[j] = i;
cnt++;
}
if (cnt > 0) mn = min(mn, cnt);
}
return mn;
};
int ans = 0;
for (int i = 1; i <= n; i++) ans = max(ans, get(i) * i);
cout << (ans == inf ? 0 : ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 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 |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 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 |
1 ms |
348 KB |
Output isn't correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 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 |
344 KB |
Output is correct |
23 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
24 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
860 KB |
Output is correct |
28 |
Correct |
3 ms |
856 KB |
Output is correct |
29 |
Incorrect |
17 ms |
860 KB |
Output isn't correct |
30 |
Incorrect |
24 ms |
1368 KB |
Output isn't correct |
31 |
Incorrect |
15 ms |
1224 KB |
Output isn't correct |
32 |
Incorrect |
20 ms |
1116 KB |
Output isn't correct |
33 |
Incorrect |
35 ms |
1372 KB |
Output isn't correct |
34 |
Correct |
2 ms |
860 KB |
Output is correct |
35 |
Incorrect |
8 ms |
1492 KB |
Output isn't correct |
36 |
Correct |
18 ms |
1372 KB |
Output is correct |
37 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
38 |
Execution timed out |
1082 ms |
31120 KB |
Time limit exceeded |
39 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
40 |
Incorrect |
425 ms |
4292 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
42 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
43 |
Execution timed out |
1074 ms |
31124 KB |
Time limit exceeded |
44 |
Incorrect |
58 ms |
1372 KB |
Output isn't correct |
45 |
Execution timed out |
1018 ms |
31064 KB |
Time limit exceeded |
46 |
Correct |
289 ms |
31068 KB |
Output is correct |
47 |
Execution timed out |
1084 ms |
31068 KB |
Time limit exceeded |
48 |
Incorrect |
469 ms |
31216 KB |
Output isn't correct |
49 |
Correct |
143 ms |
31220 KB |
Output is correct |
50 |
Incorrect |
453 ms |
31216 KB |
Output isn't correct |
51 |
Incorrect |
429 ms |
31064 KB |
Output isn't correct |
52 |
Incorrect |
495 ms |
31220 KB |
Output isn't correct |
53 |
Incorrect |
455 ms |
31216 KB |
Output isn't correct |
54 |
Correct |
766 ms |
31224 KB |
Output is correct |
55 |
Execution timed out |
1045 ms |
31064 KB |
Time limit exceeded |
56 |
Execution timed out |
1074 ms |
31068 KB |
Time limit exceeded |
57 |
Execution timed out |
1034 ms |
31068 KB |
Time limit exceeded |
58 |
Execution timed out |
1061 ms |
31068 KB |
Time limit exceeded |
59 |
Execution timed out |
1020 ms |
31064 KB |
Time limit exceeded |
60 |
Correct |
342 ms |
31068 KB |
Output is correct |
61 |
Correct |
368 ms |
31216 KB |
Output is correct |
62 |
Execution timed out |
1095 ms |
31024 KB |
Time limit exceeded |
63 |
Execution timed out |
1083 ms |
31068 KB |
Time limit exceeded |
64 |
Execution timed out |
1084 ms |
31068 KB |
Time limit exceeded |
65 |
Incorrect |
492 ms |
31220 KB |
Output isn't correct |
66 |
Incorrect |
174 ms |
31320 KB |
Output isn't correct |
67 |
Incorrect |
390 ms |
31068 KB |
Output isn't correct |
68 |
Incorrect |
444 ms |
31316 KB |
Output isn't correct |
69 |
Execution timed out |
1057 ms |
31068 KB |
Time limit exceeded |
70 |
Execution timed out |
1066 ms |
20060 KB |
Time limit exceeded |
71 |
Execution timed out |
1067 ms |
31068 KB |
Time limit exceeded |
72 |
Execution timed out |
1039 ms |
31064 KB |
Time limit exceeded |
73 |
Execution timed out |
1085 ms |
31068 KB |
Time limit exceeded |
74 |
Execution timed out |
1063 ms |
31064 KB |
Time limit exceeded |
75 |
Execution timed out |
1050 ms |
31068 KB |
Time limit exceeded |
76 |
Execution timed out |
1067 ms |
31068 KB |
Time limit exceeded |
77 |
Execution timed out |
1056 ms |
31068 KB |
Time limit exceeded |
78 |
Execution timed out |
1073 ms |
31068 KB |
Time limit exceeded |
79 |
Execution timed out |
1034 ms |
31064 KB |
Time limit exceeded |
80 |
Execution timed out |
1089 ms |
31068 KB |
Time limit exceeded |
81 |
Execution timed out |
1052 ms |
31048 KB |
Time limit exceeded |
82 |
Execution timed out |
1012 ms |
31064 KB |
Time limit exceeded |
83 |
Execution timed out |
1029 ms |
31064 KB |
Time limit exceeded |
84 |
Incorrect |
198 ms |
31224 KB |
Output isn't correct |
85 |
Execution timed out |
1016 ms |
31068 KB |
Time limit exceeded |
86 |
Correct |
390 ms |
31312 KB |
Output is correct |
87 |
Execution timed out |
1067 ms |
31068 KB |
Time limit exceeded |
88 |
Execution timed out |
1045 ms |
31068 KB |
Time limit exceeded |
89 |
Execution timed out |
1065 ms |
31068 KB |
Time limit exceeded |
90 |
Execution timed out |
1037 ms |
20060 KB |
Time limit exceeded |
91 |
Execution timed out |
1045 ms |
31064 KB |
Time limit exceeded |
92 |
Execution timed out |
1039 ms |
31220 KB |
Time limit exceeded |
93 |
Incorrect |
698 ms |
31220 KB |
Output isn't correct |
94 |
Execution timed out |
1074 ms |
31068 KB |
Time limit exceeded |
95 |
Execution timed out |
1067 ms |
31068 KB |
Time limit exceeded |
96 |
Execution timed out |
1073 ms |
31068 KB |
Time limit exceeded |
97 |
Incorrect |
544 ms |
31220 KB |
Output isn't correct |
98 |
Execution timed out |
1080 ms |
31068 KB |
Time limit exceeded |
99 |
Execution timed out |
1039 ms |
31064 KB |
Time limit exceeded |
100 |
Incorrect |
767 ms |
31220 KB |
Output isn't correct |