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 <bits/stdc++.h>
#ifdef LOCAL
#include "grader.cpp"
#else
#include "museum.h"
#endif
#define count_similar_pairs CountSimilarPairs
#define int32_t int
#define int64_t long long
int64_t count_similar_pairs(std::vector< int32_t > a, std::vector< int32_t > b, std::vector< int32_t > c) {
std::map< int32_t, int32_t > cntA, cntB, cntC;
std::map< std::pair< int32_t, int32_t >, int32_t > cntAB, cntAC, cntBC;
std::map< std::tuple< int32_t, int32_t, int32_t >, int32_t > cntABC;
int32_t n = a.size();
for(int32_t i = 0; i < n; i++) {
cntA[a[i]]++;
cntB[b[i]]++;
cntC[c[i]]++;
cntAB[{ a[i], b[i] }]++;
cntAC[{ a[i], c[i] }]++;
cntBC[{ b[i], c[i] }]++;
cntABC[{ a[i], b[i], c[i] }]++;
}
int64_t ans = 0;
for(auto &x : cntA) {
ans += (int64_t) x.second * (x.second - 1) / 2;
}
for(auto &x : cntB) {
ans += (int64_t) x.second * (x.second - 1) / 2;
}
for(auto &x : cntC) {
ans += (int64_t) x.second * (x.second - 1) / 2;
}
for(auto &x : cntAB) {
ans -= (int64_t) x.second * (x.second - 1) / 2;
}
for(auto &x : cntAC) {
ans -= (int64_t) x.second * (x.second - 1) / 2;
}
for(auto &x : cntBC) {
ans -= (int64_t) x.second * (x.second - 1) / 2;
}
for(auto &x : cntABC) {
ans += (int64_t) x.second * (x.second - 1) / 2;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |