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;
#define ll long long
template<typename T>
ll f(vector<T> v) {
map<T, int> s;
for(auto x : v) s[x] += 1;
ll r = 0;
for(auto p : s) {
ll t = p.second;
r += (t * (t - 1)) / 2;
}
return r;
}
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int N = B.size();
ll r = 0;
r += f(B);
r += f(T);
r += f(G);
vector<int> BT, TG, BG, BTG;
for(int i=0; i<N; i++) {
BT.push_back(B[i]*1000 + T[i]);
TG.push_back(T[i]*1000 + G[i]);
BG.push_back(B[i]*1000 + G[i]);
BTG.push_back(B[i]*1000000 + T[i]*1000 + G[i]);
}
r -= f(BT);
r -= f(TG);
r -= f(BG);
r += f(BTG);
return r;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |