# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1032392 |
2024-07-23T16:49:27 Z |
shmax |
Rectangles (IOI19_rect) |
C++17 |
|
3403 ms |
1048576 KB |
#include "rect.h"
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,bmi,bmi2")
using namespace std;
using i32 = int;
//#define int long long
#define len(x) (int)(x.size())
#define inf 1000'000'000'000'000'000LL
#define all(x) x.begin(), x.end()
#define low_bit(x) (x & (-x))
template<typename T>
using vec = vector<T>;
const int maxM = 701;
long long count_rectangles(std::vector<std::vector<i32>> a) {
int n = len(a);
int m = len(a[0]);
long long ans = 0;
vec<vec<bitset<maxM>>> b(n, vec<bitset<maxM>>(m));
for (int i = 1; i < n - 1; i++) {
for (int j = 1; j < m - 1; j++) {
b[i][j].reset();
int mx = a[i][j];
for (int l = i; l < n - 1; l++) {
mx = max(mx, a[l][j]);
if (mx >= min(a[i - 1][j], a[l + 1][j])) continue;
b[i][j][l] = true;
}
}
}
vec<vec<bitset<maxM>>> good(m, vec<bitset<maxM>>(m));
vec<vec<vec<int>>> maxVal(n, vec<vec<int>>(m, vec<int>(m, 0)));
for (int i = 1; i < n - 1; i++) {
for (int l = 1; l < m - 1; l++) {
for (int r = l; r < m - 1; r++) {
maxVal[i][l][r] = max(maxVal[i][l][r - 1], a[i][r]);
}
}
}
for (int l = 1; l < m - 1; l++) {
for (int r = l; r < m - 1; r++) {
for (int i = 0; i < n; i++) {
good[l][r][i] = maxVal[i][l][r] < min(a[i][l - 1], a[i][r + 1]);
}
}
}
vec<vec<vec<int>>> lowest(m, vec<vec<int>>(m, vec<int>(n, 0)));
for (int l = 1; l < m - 1; l++) {
for (int r = l; r < m - 1; r++) {
for (int i = n - 2; i >= 1; i--) {
if (!good[l][r][i]) continue;
lowest[l][r][i] = lowest[l][r][i + 1] + 1;
}
}
}
for (int i = 1; i < n - 1; i++) {
for (int j = 1; j < m - 1; j++) {
if (a[i][j] >= a[i - 1][j]) continue;
if (a[i][j] >= a[i][j - 1]) continue;
bitset<maxM> cur = b[i][j];
for (int k = j; k < m - 1; k++) {
cur &= b[i][k];
ans += (cur & ((good[j][k] << (maxM - i - lowest[j][k][i])) >> (maxM - i - lowest[j][k][i]))).count();
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
856 KB |
Output is correct |
12 |
Correct |
1 ms |
860 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 |
860 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
856 KB |
Output is correct |
12 |
Correct |
1 ms |
860 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 |
860 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
26 ms |
5984 KB |
Output is correct |
23 |
Correct |
21 ms |
5976 KB |
Output is correct |
24 |
Correct |
20 ms |
5980 KB |
Output is correct |
25 |
Correct |
7 ms |
5976 KB |
Output is correct |
26 |
Correct |
10 ms |
6076 KB |
Output is correct |
27 |
Correct |
9 ms |
6036 KB |
Output is correct |
28 |
Correct |
9 ms |
5980 KB |
Output is correct |
29 |
Correct |
3 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
856 KB |
Output is correct |
12 |
Correct |
1 ms |
860 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 |
26 ms |
5984 KB |
Output is correct |
18 |
Correct |
21 ms |
5976 KB |
Output is correct |
19 |
Correct |
20 ms |
5980 KB |
Output is correct |
20 |
Correct |
7 ms |
5976 KB |
Output is correct |
21 |
Correct |
10 ms |
6076 KB |
Output is correct |
22 |
Correct |
9 ms |
6036 KB |
Output is correct |
23 |
Correct |
9 ms |
5980 KB |
Output is correct |
24 |
Correct |
3 ms |
1880 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
860 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
302 ms |
73796 KB |
Output is correct |
31 |
Correct |
298 ms |
73560 KB |
Output is correct |
32 |
Correct |
303 ms |
73812 KB |
Output is correct |
33 |
Correct |
110 ms |
73408 KB |
Output is correct |
34 |
Correct |
143 ms |
73560 KB |
Output is correct |
35 |
Correct |
144 ms |
73812 KB |
Output is correct |
36 |
Correct |
148 ms |
73812 KB |
Output is correct |
37 |
Correct |
135 ms |
71756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
856 KB |
Output is correct |
12 |
Correct |
1 ms |
860 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 |
26 ms |
5984 KB |
Output is correct |
18 |
Correct |
21 ms |
5976 KB |
Output is correct |
19 |
Correct |
20 ms |
5980 KB |
Output is correct |
20 |
Correct |
7 ms |
5976 KB |
Output is correct |
21 |
Correct |
10 ms |
6076 KB |
Output is correct |
22 |
Correct |
9 ms |
6036 KB |
Output is correct |
23 |
Correct |
9 ms |
5980 KB |
Output is correct |
24 |
Correct |
3 ms |
1880 KB |
Output is correct |
25 |
Correct |
302 ms |
73796 KB |
Output is correct |
26 |
Correct |
298 ms |
73560 KB |
Output is correct |
27 |
Correct |
303 ms |
73812 KB |
Output is correct |
28 |
Correct |
110 ms |
73408 KB |
Output is correct |
29 |
Correct |
143 ms |
73560 KB |
Output is correct |
30 |
Correct |
144 ms |
73812 KB |
Output is correct |
31 |
Correct |
148 ms |
73812 KB |
Output is correct |
32 |
Correct |
135 ms |
71756 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
860 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Runtime error |
662 ms |
1048576 KB |
Execution killed with signal 9 |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
737 ms |
955564 KB |
Output is correct |
2 |
Correct |
517 ms |
689544 KB |
Output is correct |
3 |
Correct |
588 ms |
955768 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
620 ms |
955904 KB |
Output is correct |
6 |
Correct |
599 ms |
956024 KB |
Output is correct |
7 |
Correct |
590 ms |
955772 KB |
Output is correct |
8 |
Correct |
607 ms |
955548 KB |
Output is correct |
9 |
Correct |
589 ms |
955632 KB |
Output is correct |
10 |
Correct |
516 ms |
906100 KB |
Output is correct |
11 |
Correct |
508 ms |
931000 KB |
Output is correct |
# |
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 |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Runtime error |
3403 ms |
1048576 KB |
Execution killed with signal 9 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
856 KB |
Output is correct |
12 |
Correct |
1 ms |
860 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 |
26 ms |
5984 KB |
Output is correct |
18 |
Correct |
21 ms |
5976 KB |
Output is correct |
19 |
Correct |
20 ms |
5980 KB |
Output is correct |
20 |
Correct |
7 ms |
5976 KB |
Output is correct |
21 |
Correct |
10 ms |
6076 KB |
Output is correct |
22 |
Correct |
9 ms |
6036 KB |
Output is correct |
23 |
Correct |
9 ms |
5980 KB |
Output is correct |
24 |
Correct |
3 ms |
1880 KB |
Output is correct |
25 |
Correct |
302 ms |
73796 KB |
Output is correct |
26 |
Correct |
298 ms |
73560 KB |
Output is correct |
27 |
Correct |
303 ms |
73812 KB |
Output is correct |
28 |
Correct |
110 ms |
73408 KB |
Output is correct |
29 |
Correct |
143 ms |
73560 KB |
Output is correct |
30 |
Correct |
144 ms |
73812 KB |
Output is correct |
31 |
Correct |
148 ms |
73812 KB |
Output is correct |
32 |
Correct |
135 ms |
71756 KB |
Output is correct |
33 |
Runtime error |
662 ms |
1048576 KB |
Execution killed with signal 9 |
34 |
Halted |
0 ms |
0 KB |
- |