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"
#include <algorithm>
using namespace std;
typedef long long ll;
int cnt[101][101][101];
long long nC2(ll n){
return n * (n - 1) / 2;
}
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int N = B.size();
for(int i = 0; i < N; i++)
cnt[B[i]][T[i]][G[i]]++;
ll ans = 0;
for(int i = 1; i <= 100; i++){
int s1 = 0, s2 = 0, s3 = 0;
for(int j = 1; j <= 100; j++){
int d12 = 0, d13 = 0, d23 = 0;
for(int k = 1; k <= 100; k++){
s1 += cnt[i][j][k];
s2 += cnt[j][i][k];
s3 += cnt[j][k][i];
d12 += cnt[i][j][k];
d13 += cnt[i][k][j];
d23 += cnt[k][i][j];
ans += nC2(cnt[i][j][k]);
}
ans -= nC2(d12); ans -= nC2(d13); ans -= nC2(d23);
}
ans += nC2(s1); ans += nC2(s2); ans += nC2(s3);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |