# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
854637 |
2023-09-28T09:07:35 Z |
The_Samurai |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
31392 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) {
if (i - last[j] >= h) return 0;
cnt++;
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;
}
# |
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 |
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 |
1 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 |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
20 |
Incorrect |
1 ms |
504 KB |
Output isn't correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
344 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 |
860 KB |
Output is correct |
29 |
Incorrect |
19 ms |
1104 KB |
Output isn't correct |
30 |
Incorrect |
33 ms |
1372 KB |
Output isn't correct |
31 |
Incorrect |
19 ms |
1112 KB |
Output isn't correct |
32 |
Incorrect |
28 ms |
1116 KB |
Output isn't correct |
33 |
Incorrect |
45 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 |
21 ms |
1492 KB |
Output is correct |
37 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
38 |
Execution timed out |
1096 ms |
31020 KB |
Time limit exceeded |
39 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
40 |
Incorrect |
438 ms |
4292 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
42 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
43 |
Execution timed out |
1031 ms |
31064 KB |
Time limit exceeded |
44 |
Incorrect |
66 ms |
1624 KB |
Output isn't correct |
45 |
Execution timed out |
1078 ms |
31068 KB |
Time limit exceeded |
46 |
Correct |
356 ms |
31220 KB |
Output is correct |
47 |
Execution timed out |
1050 ms |
31064 KB |
Time limit exceeded |
48 |
Incorrect |
514 ms |
31224 KB |
Output isn't correct |
49 |
Correct |
145 ms |
31224 KB |
Output is correct |
50 |
Incorrect |
500 ms |
31216 KB |
Output isn't correct |
51 |
Incorrect |
482 ms |
31264 KB |
Output isn't correct |
52 |
Incorrect |
518 ms |
31068 KB |
Output isn't correct |
53 |
Incorrect |
492 ms |
31216 KB |
Output isn't correct |
54 |
Correct |
900 ms |
31216 KB |
Output is correct |
55 |
Execution timed out |
1055 ms |
31068 KB |
Time limit exceeded |
56 |
Execution timed out |
1044 ms |
31068 KB |
Time limit exceeded |
57 |
Execution timed out |
1043 ms |
31064 KB |
Time limit exceeded |
58 |
Execution timed out |
1041 ms |
31064 KB |
Time limit exceeded |
59 |
Execution timed out |
1044 ms |
31068 KB |
Time limit exceeded |
60 |
Correct |
358 ms |
31220 KB |
Output is correct |
61 |
Correct |
377 ms |
31064 KB |
Output is correct |
62 |
Execution timed out |
1074 ms |
31068 KB |
Time limit exceeded |
63 |
Execution timed out |
1060 ms |
31024 KB |
Time limit exceeded |
64 |
Execution timed out |
1026 ms |
31064 KB |
Time limit exceeded |
65 |
Incorrect |
579 ms |
31220 KB |
Output isn't correct |
66 |
Incorrect |
170 ms |
31392 KB |
Output isn't correct |
67 |
Incorrect |
423 ms |
31068 KB |
Output isn't correct |
68 |
Incorrect |
454 ms |
31216 KB |
Output isn't correct |
69 |
Execution timed out |
1055 ms |
31068 KB |
Time limit exceeded |
70 |
Execution timed out |
1069 ms |
20060 KB |
Time limit exceeded |
71 |
Execution timed out |
1072 ms |
31068 KB |
Time limit exceeded |
72 |
Execution timed out |
1051 ms |
31068 KB |
Time limit exceeded |
73 |
Execution timed out |
1041 ms |
31064 KB |
Time limit exceeded |
74 |
Execution timed out |
1045 ms |
31064 KB |
Time limit exceeded |
75 |
Execution timed out |
1058 ms |
31068 KB |
Time limit exceeded |
76 |
Execution timed out |
1035 ms |
31064 KB |
Time limit exceeded |
77 |
Execution timed out |
1044 ms |
31060 KB |
Time limit exceeded |
78 |
Execution timed out |
1057 ms |
31068 KB |
Time limit exceeded |
79 |
Execution timed out |
1047 ms |
31068 KB |
Time limit exceeded |
80 |
Execution timed out |
1012 ms |
31064 KB |
Time limit exceeded |
81 |
Execution timed out |
1046 ms |
31068 KB |
Time limit exceeded |
82 |
Execution timed out |
1069 ms |
31068 KB |
Time limit exceeded |
83 |
Execution timed out |
1079 ms |
31068 KB |
Time limit exceeded |
84 |
Incorrect |
246 ms |
31224 KB |
Output isn't correct |
85 |
Execution timed out |
1046 ms |
31064 KB |
Time limit exceeded |
86 |
Correct |
401 ms |
31220 KB |
Output is correct |
87 |
Execution timed out |
1061 ms |
31068 KB |
Time limit exceeded |
88 |
Execution timed out |
1082 ms |
31068 KB |
Time limit exceeded |
89 |
Execution timed out |
1071 ms |
31068 KB |
Time limit exceeded |
90 |
Execution timed out |
1044 ms |
20056 KB |
Time limit exceeded |
91 |
Execution timed out |
1067 ms |
31068 KB |
Time limit exceeded |
92 |
Execution timed out |
1059 ms |
31068 KB |
Time limit exceeded |
93 |
Incorrect |
717 ms |
31220 KB |
Output isn't correct |
94 |
Execution timed out |
1066 ms |
31068 KB |
Time limit exceeded |
95 |
Execution timed out |
1070 ms |
31068 KB |
Time limit exceeded |
96 |
Execution timed out |
1057 ms |
31068 KB |
Time limit exceeded |
97 |
Incorrect |
437 ms |
31216 KB |
Output isn't correct |
98 |
Execution timed out |
1068 ms |
31068 KB |
Time limit exceeded |
99 |
Execution timed out |
1030 ms |
31064 KB |
Time limit exceeded |
100 |
Incorrect |
780 ms |
31220 KB |
Output isn't correct |