# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
854633 |
2023-09-28T08:54:44 Z |
The_Samurai |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
31440 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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 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 |
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 |
1 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 |
348 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 |
1 ms |
348 KB |
Output is correct |
20 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
24 |
Incorrect |
2 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 |
3 ms |
860 KB |
Output is correct |
28 |
Correct |
3 ms |
860 KB |
Output is correct |
29 |
Incorrect |
23 ms |
1356 KB |
Output isn't correct |
30 |
Incorrect |
29 ms |
1372 KB |
Output isn't correct |
31 |
Incorrect |
20 ms |
1112 KB |
Output isn't correct |
32 |
Incorrect |
27 ms |
1260 KB |
Output isn't correct |
33 |
Incorrect |
42 ms |
1372 KB |
Output isn't correct |
34 |
Correct |
2 ms |
868 KB |
Output is correct |
35 |
Incorrect |
9 ms |
1276 KB |
Output isn't correct |
36 |
Correct |
18 ms |
1368 KB |
Output is correct |
37 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
38 |
Execution timed out |
1068 ms |
31068 KB |
Time limit exceeded |
39 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
40 |
Incorrect |
497 ms |
4296 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
42 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
43 |
Execution timed out |
1091 ms |
31076 KB |
Time limit exceeded |
44 |
Incorrect |
76 ms |
1368 KB |
Output isn't correct |
45 |
Execution timed out |
1104 ms |
31064 KB |
Time limit exceeded |
46 |
Correct |
301 ms |
31068 KB |
Output is correct |
47 |
Execution timed out |
1069 ms |
31068 KB |
Time limit exceeded |
48 |
Incorrect |
489 ms |
31216 KB |
Output isn't correct |
49 |
Correct |
142 ms |
31064 KB |
Output is correct |
50 |
Incorrect |
492 ms |
31216 KB |
Output isn't correct |
51 |
Incorrect |
512 ms |
31316 KB |
Output isn't correct |
52 |
Incorrect |
530 ms |
31220 KB |
Output isn't correct |
53 |
Incorrect |
494 ms |
31216 KB |
Output isn't correct |
54 |
Execution timed out |
1066 ms |
31068 KB |
Time limit exceeded |
55 |
Execution timed out |
1066 ms |
31068 KB |
Time limit exceeded |
56 |
Execution timed out |
1004 ms |
31064 KB |
Time limit exceeded |
57 |
Execution timed out |
1090 ms |
31440 KB |
Time limit exceeded |
58 |
Execution timed out |
1072 ms |
31068 KB |
Time limit exceeded |
59 |
Execution timed out |
1040 ms |
31068 KB |
Time limit exceeded |
60 |
Correct |
362 ms |
31216 KB |
Output is correct |
61 |
Correct |
485 ms |
31216 KB |
Output is correct |
62 |
Execution timed out |
1081 ms |
31068 KB |
Time limit exceeded |
63 |
Execution timed out |
1052 ms |
31068 KB |
Time limit exceeded |
64 |
Execution timed out |
1058 ms |
31128 KB |
Time limit exceeded |
65 |
Incorrect |
543 ms |
31216 KB |
Output isn't correct |
66 |
Incorrect |
171 ms |
31220 KB |
Output isn't correct |
67 |
Incorrect |
482 ms |
31220 KB |
Output isn't correct |
68 |
Incorrect |
598 ms |
31232 KB |
Output isn't correct |
69 |
Execution timed out |
1048 ms |
31068 KB |
Time limit exceeded |
70 |
Execution timed out |
1057 ms |
20060 KB |
Time limit exceeded |
71 |
Execution timed out |
1016 ms |
31068 KB |
Time limit exceeded |
72 |
Execution timed out |
1078 ms |
31064 KB |
Time limit exceeded |
73 |
Execution timed out |
1040 ms |
31068 KB |
Time limit exceeded |
74 |
Execution timed out |
1018 ms |
31064 KB |
Time limit exceeded |
75 |
Execution timed out |
1047 ms |
31068 KB |
Time limit exceeded |
76 |
Execution timed out |
1073 ms |
31068 KB |
Time limit exceeded |
77 |
Execution timed out |
1054 ms |
31068 KB |
Time limit exceeded |
78 |
Execution timed out |
1067 ms |
31068 KB |
Time limit exceeded |
79 |
Execution timed out |
1020 ms |
31068 KB |
Time limit exceeded |
80 |
Execution timed out |
1061 ms |
31068 KB |
Time limit exceeded |
81 |
Execution timed out |
1042 ms |
31064 KB |
Time limit exceeded |
82 |
Execution timed out |
1028 ms |
31064 KB |
Time limit exceeded |
83 |
Execution timed out |
1034 ms |
31068 KB |
Time limit exceeded |
84 |
Incorrect |
244 ms |
31224 KB |
Output isn't correct |
85 |
Execution timed out |
1049 ms |
31188 KB |
Time limit exceeded |
86 |
Correct |
389 ms |
31220 KB |
Output is correct |
87 |
Execution timed out |
1029 ms |
31064 KB |
Time limit exceeded |
88 |
Execution timed out |
1076 ms |
31068 KB |
Time limit exceeded |
89 |
Execution timed out |
1044 ms |
31068 KB |
Time limit exceeded |
90 |
Execution timed out |
1012 ms |
20056 KB |
Time limit exceeded |
91 |
Execution timed out |
1053 ms |
31064 KB |
Time limit exceeded |
92 |
Execution timed out |
1042 ms |
31064 KB |
Time limit exceeded |
93 |
Incorrect |
679 ms |
31320 KB |
Output isn't correct |
94 |
Execution timed out |
1064 ms |
31068 KB |
Time limit exceeded |
95 |
Execution timed out |
1050 ms |
31068 KB |
Time limit exceeded |
96 |
Execution timed out |
1062 ms |
31068 KB |
Time limit exceeded |
97 |
Incorrect |
434 ms |
31064 KB |
Output isn't correct |
98 |
Execution timed out |
1041 ms |
30984 KB |
Time limit exceeded |
99 |
Execution timed out |
1066 ms |
31068 KB |
Time limit exceeded |
100 |
Incorrect |
782 ms |
31312 KB |
Output isn't correct |