#include "museum.h"
#include <iostream>
using namespace std;
int d[102][102][102], e[102][102][102];
int sum(int x1, int y1, int z1, int x2, int y2, int z2) {
return d[x2][y2][z2] - d[x1 - 1][y2][z2] - d[x2][y1 - 1][z2] - d[x2][y2][z1 - 1] + d[x1 - 1][y1 - 1][z2] + d[x1 - 1][y2][z1 - 1] + d[x2][y1 - 1][z1 - 1] - d[x1 - 1][y1 - 1][z1 - 1];
}
long long CountSimilarPairs(std::vector<int> a, std::vector<int> b, std::vector<int> c) {
int n = (int)a.size();
for (int i = 0; i < n; i++) d[a[i]][b[i]][c[i]]++;
for (int i = 1; i <= 100; i++) for (int j = 1; j <= 100; j++) for (int k = 1; k <= 100; k++) d[i][j][k] += d[i - 1][j][k] + d[i][j - 1][k] + d[i][j][k - 1] - d[i - 1][j - 1][k] - d[i - 1][j][k - 1] - d[i][j - 1][k - 1] + d[i - 1][j - 1][k - 1];
for (int i = 1; i <= 100; i++) for (int j = 1; j <= 100; j++) for (int k = 1; k <= 100; k++) e[i][j][k] = sum(i, 1, 1, i, 100, 100) + sum(1, j, 1, 100, j, 100) + sum(1, 1, k, 100, 100, k) - sum(i, j, 1, i, j, 100) - sum(i, 1, k, i, 100, k) - sum(1, j, k, 100, j, k) + sum(i, j, k, i, j, k);
long long z = 0;
for (int i = 0; i < n; i++) z += e[a[i]][b[i]][c[i]];
return (z - n) / 2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
8576 KB |
Output is correct |
2 |
Correct |
27 ms |
8576 KB |
Output is correct |
3 |
Correct |
29 ms |
8568 KB |
Output is correct |
4 |
Correct |
28 ms |
8568 KB |
Output is correct |
5 |
Correct |
27 ms |
8572 KB |
Output is correct |
6 |
Correct |
28 ms |
8576 KB |
Output is correct |
7 |
Correct |
29 ms |
8572 KB |
Output is correct |
8 |
Correct |
27 ms |
8568 KB |
Output is correct |
9 |
Correct |
30 ms |
8568 KB |
Output is correct |
10 |
Correct |
27 ms |
8568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
8576 KB |
Output is correct |
2 |
Correct |
27 ms |
8576 KB |
Output is correct |
3 |
Correct |
29 ms |
8568 KB |
Output is correct |
4 |
Correct |
28 ms |
8568 KB |
Output is correct |
5 |
Correct |
27 ms |
8572 KB |
Output is correct |
6 |
Correct |
28 ms |
8576 KB |
Output is correct |
7 |
Correct |
29 ms |
8572 KB |
Output is correct |
8 |
Correct |
27 ms |
8568 KB |
Output is correct |
9 |
Correct |
30 ms |
8568 KB |
Output is correct |
10 |
Correct |
27 ms |
8568 KB |
Output is correct |
11 |
Correct |
30 ms |
8704 KB |
Output is correct |
12 |
Correct |
38 ms |
9336 KB |
Output is correct |
13 |
Correct |
52 ms |
9936 KB |
Output is correct |
14 |
Correct |
58 ms |
10608 KB |
Output is correct |
15 |
Correct |
81 ms |
11500 KB |
Output is correct |
16 |
Correct |
97 ms |
13412 KB |
Output is correct |
17 |
Correct |
93 ms |
13292 KB |
Output is correct |
18 |
Correct |
105 ms |
13412 KB |
Output is correct |
19 |
Correct |
105 ms |
13416 KB |
Output is correct |
20 |
Correct |
111 ms |
13164 KB |
Output is correct |