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 <map>
#include <utility>
#include <tuple>
using namespace std;
using ll = long long;
long long CountSimilarPairs(vector<int> b, vector<int> t, vector<int> g) {
const int n = b.size();
ll res = 0;
vector v({b, t, g});
for (int i = 0; i < 3; i++) {
map<int, int> cnt;
for (int e : v[i]) {
res += cnt[e];
cnt[e]++;
}
}
for (int i = 0; i < 3; i++) {
for (int j = i + 1; j < 3; j++) {
map<pair<int, int>, int> cnt;
for (int k = 0; k < n; k++) {
const pair p(v[i][k], v[j][k]);
res -= cnt[p];
cnt[p]++;
}
}
}
map<tuple<int, int, int>, int> cnt;
for (int i = 0; i < n; i++) {
const tuple T(b[i], t[i], g[i]);
res += cnt[T];
cnt[T]++;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |