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<bits/stdc++.h>
using namespace std;
template<typename T>
long long s(vector<T> V)
{
sort(V.begin(), V.end());
int N = V.size();
long long ans = 0;
int cnt = 1;
for(int i=1; i<N; ++i)
{
if(V[i] == V[i-1]) ++cnt;
else
{
ans += 1LL*cnt*(cnt-1)/2;
cnt = 1;
}
}
return ans + 1LL*cnt*(cnt-1)/2;
}
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int N = B.size();
vector<tuple<int, int, int>> V;
for(int i=0; i<N; ++i)
V.emplace_back(B[i], T[i], G[i]);
vector<pair<int, int> > X;
long long os = s(B) + s(T) + s(G);
X.clear();
for(int i=0; i<N; ++i)
X.emplace_back(B[i], T[i]);
os -= s(X);
X.clear();
for(int i=0; i<N; ++i)
X.emplace_back(G[i], T[i]);
os -= s(X);
X.clear();
for(int i=0; i<N; ++i)
X.emplace_back(B[i], G[i]);
os -= s(X);
os += s(V);
return os;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |