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;
using ll = long long;
ll s1(vector<int> A){
map<int, ll> freq;
for(int x : A){
freq[x]++;
}
ll ans = 0;
for(auto r : freq){
ans += r.second * r.second;
}
return ans;
}
ll s2(vector<int> A, vector<int> B){
map<int, ll> freq;
for(int i = 0; i < (int)A.size(); i++){
freq[A[i] + B[i] * 200]++;
}
ll ans = 0;
for(auto r : freq){
ans += r.second * r.second;
}
return ans;
}
ll s3(vector<int> A, vector<int> B, vector<int> C){
map<int, ll> freq;
for(int i = 0; i < (int)A.size(); i++){
freq[A[i] + B[i] * 200 + C[i] * 40000]++;
}
ll ans = 0;
for(auto r : freq){
ans += r.second * r.second;
}
return ans;
}
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
using namespace std;
ll ans = s1(B) + s1(T) + s1(G) - s2(B, T) - s2(B, G) - s2(T, G) + s3(B, T, G);
return (ans - (int)B.size()) / 2;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |