이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |