#include <stdio.h>
#include "museum.h"
typedef long long lli;
lli a[101], b[101], c[101];
lli ab[101][101], ac[101][101], bc[101][101];
lli abc[101][101][101];
lli c2(lli x) {
return x*(x-1)/2;
}
int n, x[200000], y[200000], z[200000];
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
n=B.size();
for(int i=0;i<n;i++) {
x[i]=B[i]; y[i]=T[i]; z[i]=G[i];
a[x[i]]++; b[y[i]]++; c[z[i]]++;
ab[x[i]][y[i]]++; ac[x[i]][z[i]]++; bc[y[i]][z[i]]++;
abc[x[i]][y[i]][z[i]]++;
}
lli res=0;
for(int i=1;i<=100;i++) {
res+=c2(a[i]);
res+=c2(b[i]);
res+=c2(c[i]);
}
for(int i=1;i<=100;i++) {
for(int j=1;j<=100;j++) {
res-=c2(ab[i][j]);
res-=c2(ac[i][j]);
res-=c2(bc[i][j]);
}
}
for(int i=1;i<=100;i++) {
for(int j=1;j<=100;j++) {
for(int k=1;k<=100;k++)
res+=c2(abc[i][j][k]);
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
384 KB |
Output is correct |
2 |
Correct |
9 ms |
512 KB |
Output is correct |
3 |
Correct |
8 ms |
512 KB |
Output is correct |
4 |
Correct |
9 ms |
768 KB |
Output is correct |
5 |
Correct |
9 ms |
1920 KB |
Output is correct |
6 |
Correct |
9 ms |
2688 KB |
Output is correct |
7 |
Correct |
10 ms |
3712 KB |
Output is correct |
8 |
Correct |
8 ms |
640 KB |
Output is correct |
9 |
Correct |
10 ms |
5888 KB |
Output is correct |
10 |
Correct |
11 ms |
5760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
384 KB |
Output is correct |
2 |
Correct |
9 ms |
512 KB |
Output is correct |
3 |
Correct |
8 ms |
512 KB |
Output is correct |
4 |
Correct |
9 ms |
768 KB |
Output is correct |
5 |
Correct |
9 ms |
1920 KB |
Output is correct |
6 |
Correct |
9 ms |
2688 KB |
Output is correct |
7 |
Correct |
10 ms |
3712 KB |
Output is correct |
8 |
Correct |
8 ms |
640 KB |
Output is correct |
9 |
Correct |
10 ms |
5888 KB |
Output is correct |
10 |
Correct |
11 ms |
5760 KB |
Output is correct |
11 |
Correct |
13 ms |
8320 KB |
Output is correct |
12 |
Correct |
21 ms |
1536 KB |
Output is correct |
13 |
Correct |
34 ms |
9460 KB |
Output is correct |
14 |
Correct |
48 ms |
11632 KB |
Output is correct |
15 |
Correct |
62 ms |
13044 KB |
Output is correct |
16 |
Correct |
84 ms |
7400 KB |
Output is correct |
17 |
Correct |
86 ms |
7656 KB |
Output is correct |
18 |
Correct |
92 ms |
9836 KB |
Output is correct |
19 |
Correct |
97 ms |
15752 KB |
Output is correct |
20 |
Correct |
100 ms |
15844 KB |
Output is correct |