# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
854582 |
2023-09-28T06:05:29 Z |
The_Samurai |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
55792 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("game.in", "r", stdin);
// freopen("game.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];
};
vector<vector<int>> checked(n + 1, vector<int>(m + 1));
int z = 0;
auto check = [&](int h, int w) {
z++;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == '0') continue;
if (i + h - 1 <= n and j + w - 1 <= m and get_sum(i, j, i + h - 1, j + w - 1) == h * w) {
for (int x = i; x < i + h; x++) {
for (int y = j; y < j + w; y++) {
checked[x][y] = z;
}
}
}
if (checked[i][j] < z) return false;
}
}
return true;
};
vector<int> best(n + 1, -1);
auto get = [&](int h) {
if (best[h] != -1) return best[h];
int lx = 1, rx = (h > 1 ? best[h - 1] : m);
best[h] = 0;
while (lx <= rx) {
int mid = (lx + rx) >> 1;
if (check(h, mid)) {
best[h] = mid;
lx = mid + 1;
} else {
rx = mid - 1;
}
}
return best[h];
};
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 |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
872 KB |
Output is correct |
4 |
Correct |
4 ms |
880 KB |
Output is correct |
5 |
Correct |
1 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 |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
500 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 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
5 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
4 ms |
348 KB |
Output is correct |
26 |
Correct |
12 ms |
556 KB |
Output is correct |
27 |
Correct |
2 ms |
1116 KB |
Output is correct |
28 |
Correct |
3 ms |
1368 KB |
Output is correct |
29 |
Execution timed out |
1093 ms |
1436 KB |
Time limit exceeded |
30 |
Correct |
195 ms |
2144 KB |
Output is correct |
31 |
Correct |
206 ms |
1628 KB |
Output is correct |
32 |
Correct |
84 ms |
1628 KB |
Output is correct |
33 |
Correct |
791 ms |
2392 KB |
Output is correct |
34 |
Correct |
3 ms |
1116 KB |
Output is correct |
35 |
Correct |
15 ms |
2304 KB |
Output is correct |
36 |
Execution timed out |
1014 ms |
2140 KB |
Time limit exceeded |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Execution timed out |
1081 ms |
55556 KB |
Time limit exceeded |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Execution timed out |
1083 ms |
7260 KB |
Time limit exceeded |
41 |
Correct |
0 ms |
344 KB |
Output is correct |
42 |
Correct |
70 ms |
344 KB |
Output is correct |
43 |
Execution timed out |
1055 ms |
55636 KB |
Time limit exceeded |
44 |
Execution timed out |
1061 ms |
2140 KB |
Time limit exceeded |
45 |
Execution timed out |
1045 ms |
55632 KB |
Time limit exceeded |
46 |
Execution timed out |
1068 ms |
55540 KB |
Time limit exceeded |
47 |
Execution timed out |
1014 ms |
55632 KB |
Time limit exceeded |
48 |
Execution timed out |
1048 ms |
55636 KB |
Time limit exceeded |
49 |
Execution timed out |
1070 ms |
55636 KB |
Time limit exceeded |
50 |
Execution timed out |
1014 ms |
55632 KB |
Time limit exceeded |
51 |
Execution timed out |
1048 ms |
55632 KB |
Time limit exceeded |
52 |
Execution timed out |
1077 ms |
55628 KB |
Time limit exceeded |
53 |
Execution timed out |
1064 ms |
55596 KB |
Time limit exceeded |
54 |
Execution timed out |
1056 ms |
55636 KB |
Time limit exceeded |
55 |
Execution timed out |
1049 ms |
55628 KB |
Time limit exceeded |
56 |
Execution timed out |
1060 ms |
55636 KB |
Time limit exceeded |
57 |
Execution timed out |
1058 ms |
55636 KB |
Time limit exceeded |
58 |
Execution timed out |
1035 ms |
55636 KB |
Time limit exceeded |
59 |
Execution timed out |
1018 ms |
55636 KB |
Time limit exceeded |
60 |
Execution timed out |
1082 ms |
55764 KB |
Time limit exceeded |
61 |
Execution timed out |
1058 ms |
55636 KB |
Time limit exceeded |
62 |
Execution timed out |
1043 ms |
55632 KB |
Time limit exceeded |
63 |
Execution timed out |
1078 ms |
55636 KB |
Time limit exceeded |
64 |
Execution timed out |
1092 ms |
55632 KB |
Time limit exceeded |
65 |
Execution timed out |
1044 ms |
55636 KB |
Time limit exceeded |
66 |
Execution timed out |
1063 ms |
55556 KB |
Time limit exceeded |
67 |
Execution timed out |
1067 ms |
55552 KB |
Time limit exceeded |
68 |
Execution timed out |
1036 ms |
55556 KB |
Time limit exceeded |
69 |
Execution timed out |
1036 ms |
55632 KB |
Time limit exceeded |
70 |
Execution timed out |
1033 ms |
35664 KB |
Time limit exceeded |
71 |
Execution timed out |
1060 ms |
55540 KB |
Time limit exceeded |
72 |
Execution timed out |
1064 ms |
55636 KB |
Time limit exceeded |
73 |
Execution timed out |
1031 ms |
55540 KB |
Time limit exceeded |
74 |
Execution timed out |
1030 ms |
55544 KB |
Time limit exceeded |
75 |
Execution timed out |
1049 ms |
55540 KB |
Time limit exceeded |
76 |
Execution timed out |
1044 ms |
55544 KB |
Time limit exceeded |
77 |
Execution timed out |
1014 ms |
55636 KB |
Time limit exceeded |
78 |
Execution timed out |
1045 ms |
55632 KB |
Time limit exceeded |
79 |
Execution timed out |
1050 ms |
55632 KB |
Time limit exceeded |
80 |
Execution timed out |
1060 ms |
55636 KB |
Time limit exceeded |
81 |
Execution timed out |
1043 ms |
55544 KB |
Time limit exceeded |
82 |
Execution timed out |
1034 ms |
55632 KB |
Time limit exceeded |
83 |
Execution timed out |
1065 ms |
55540 KB |
Time limit exceeded |
84 |
Correct |
252 ms |
55792 KB |
Output is correct |
85 |
Execution timed out |
1071 ms |
55636 KB |
Time limit exceeded |
86 |
Execution timed out |
1050 ms |
55632 KB |
Time limit exceeded |
87 |
Execution timed out |
1032 ms |
55632 KB |
Time limit exceeded |
88 |
Execution timed out |
1067 ms |
55636 KB |
Time limit exceeded |
89 |
Execution timed out |
1066 ms |
55700 KB |
Time limit exceeded |
90 |
Execution timed out |
1035 ms |
35668 KB |
Time limit exceeded |
91 |
Execution timed out |
1066 ms |
55560 KB |
Time limit exceeded |
92 |
Execution timed out |
1022 ms |
55552 KB |
Time limit exceeded |
93 |
Execution timed out |
1020 ms |
55552 KB |
Time limit exceeded |
94 |
Execution timed out |
1073 ms |
55636 KB |
Time limit exceeded |
95 |
Execution timed out |
1058 ms |
55544 KB |
Time limit exceeded |
96 |
Execution timed out |
1071 ms |
55556 KB |
Time limit exceeded |
97 |
Execution timed out |
1083 ms |
55632 KB |
Time limit exceeded |
98 |
Execution timed out |
1072 ms |
55632 KB |
Time limit exceeded |
99 |
Execution timed out |
1057 ms |
55636 KB |
Time limit exceeded |
100 |
Execution timed out |
1048 ms |
55636 KB |
Time limit exceeded |