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;
long long CountSimilarPairs(vector<int> B, vector<int> T, vector<int> G) {
int N = B.size();
vector<vector<int> > v;
v.push_back(B); v.push_back(T); v.push_back(G);
long long ans = 0;
for(int i = 0; i < 3; i++) {
multiset<int> m;
for(int j = 0; j < N; j++) {
ans += m.count(v[i][j]);
m.insert(v[i][j]);
}
}
for(int i = 0; i < 3; i++) {
multiset<pair<int,int> > m;
for(int j = 0; j < N; j++) {
ans -= m.count({v[(i+1)%3][j], v[(i+2)%3][j]});
m.insert({v[(i+1)%3][j], v[(i+2)%3][j]});
}
}
multiset<pair<pair<int,int>, int> > m;
for(int i = 0; i < N; i++) {
ans += m.count({{v[0][i], v[1][i]}, v[2][i]});
m.insert({{v[0][i], v[1][i]}, v[2][i]});
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |