This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "museum.h"
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
long long a[20]={0, }, b[20]={0, }, c[20]={0, }, ab[300] = {0, }, bc[300] = {0,}, ac[300] = {0,}, abc[4200] = {0,};
int N = B.size();
for(int i=0; i<N; i++){
int na = B[i], nb = T[i], nc = G[i];
a[na]++, b[nb]++, c[nc]++;
ab[na*15+nb]++, ac[na*15+nc]++, bc[nb*15+nc]++;
abc[na*15*15 + nb*15 + nc]++;
}
long long ans = 0;
for(int i=0; i<20; i++){
ans += (a[i] * (a[i]-1) / 2);
ans += (b[i] * (b[i]-1) / 2);
ans += (c[i] * (c[i]-1) / 2);
}
for(int i=0; i<300; i++){
ans -= (ab[i] * (ab[i]-1) / 2);
ans -= (ac[i] * (ac[i]-1) / 2);
ans -= (bc[i] * (bc[i]-1) / 2);
}
for(int i=0; i<4100; i++){
ans += (abc[i] * (abc[i]-1) / 2);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |