#include "museum.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int b[101];
int t[101];
int g[101];
int bt[101][101];
int bg[101][101];
int tg[101][101];
int btg[101][101][101];
ll C2(int x) {
return 1ll * x * (x - 1ll) / 2ll;
}
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int N = B.size();
int i;
for (i = 0; i < N; i++) {
b[B[i]]++;
t[T[i]]++;
g[G[i]]++;
bt[B[i]][T[i]]++;
bg[B[i]][G[i]]++;
tg[T[i]][G[i]]++;
btg[B[i]][T[i]][G[i]]++;
}
int j, k;
ll ans = 0;
for (i = 1; i <= 100; i++) {
ans += C2(b[i]);
ans += C2(t[i]);
ans += C2(g[i]);
}
for (i = 1; i <= 100; i++) for (j = 1; j <= 100; j++) {
ans -= C2(bt[i][j]);
ans -= C2(bg[i][j]);
ans -= C2(tg[i][j]);
}
for (i = 1; i <= 100; i++) for (j = 1; j <= 100; j++) for (k = 1; k <= 100; k++) ans += C2(btg[i][j][k]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
596 KB |
Output is correct |
5 |
Correct |
2 ms |
1620 KB |
Output is correct |
6 |
Correct |
2 ms |
2132 KB |
Output is correct |
7 |
Correct |
3 ms |
2900 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
3 ms |
3924 KB |
Output is correct |
10 |
Correct |
3 ms |
3904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
596 KB |
Output is correct |
5 |
Correct |
2 ms |
1620 KB |
Output is correct |
6 |
Correct |
2 ms |
2132 KB |
Output is correct |
7 |
Correct |
3 ms |
2900 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
3 ms |
3924 KB |
Output is correct |
10 |
Correct |
3 ms |
3904 KB |
Output is correct |
11 |
Correct |
5 ms |
4564 KB |
Output is correct |
12 |
Correct |
7 ms |
1236 KB |
Output is correct |
13 |
Correct |
15 ms |
5792 KB |
Output is correct |
14 |
Correct |
18 ms |
7164 KB |
Output is correct |
15 |
Correct |
26 ms |
8444 KB |
Output is correct |
16 |
Correct |
37 ms |
6216 KB |
Output is correct |
17 |
Correct |
52 ms |
6472 KB |
Output is correct |
18 |
Correct |
41 ms |
8008 KB |
Output is correct |
19 |
Correct |
41 ms |
10976 KB |
Output is correct |
20 |
Correct |
41 ms |
10932 KB |
Output is correct |