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;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<p, ll> pp;
map<ll, ll> aa;
map<p, ll> bb;
map<pp, ll> cc;
long long CountSimilarPairs(std::vector<int> a, std::vector<int> b, std::vector<int> c) {
int n = b.size();
ll ans = 0;
//A
for(int i=0; i<n; i++){
aa[a[i]]++;
}
for(auto i : aa){
ans += i.second * (i.second - 1) / 2;
}
aa.clear();
//B
for(int i=0; i<n; i++){
aa[b[i]]++;
}
for(auto i : aa){
ans += i.second * (i.second - 1) / 2;
}
aa.clear();
//C
for(int i=0; i<n; i++){
aa[c[i]]++;
}
for(auto i : aa){
ans += i.second * (i.second - 1) / 2;
}
aa.clear();
//AB
for(int i=0; i<n; i++){
p now = make_pair(a[i], b[i]);
bb[now]++;
}
for(auto i : bb){
ans -= i.second * (i.second - 1) / 2;
}
bb.clear();
//BC
for(int i=0; i<n; i++){
p now = make_pair(b[i], c[i]);
bb[now]++;
}
for(auto i : bb){
ans -= i.second * (i.second - 1) / 2;
}
bb.clear();
//CA
for(int i=0; i<n; i++){
p now = make_pair(c[i], a[i]);
bb[now]++;
}
for(auto i : bb){
ans -= i.second * (i.second - 1) / 2;
}
bb.clear();
//ABC
for(int i=0; i<n; i++){
p tmp = make_pair(a[i], b[i]);
pp now = make_pair(tmp, c[i]);
cc[now]++;
}
for(auto i : cc){
ans += i.second * (i.second - 1) / 2;
}
cc.clear();
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |