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(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int n = B.size();
typedef long long ll;
ll ans = 0;
vector<int> f[7];
for (int i = 0; i < 3; i++) {
f[i].assign(100, 0);
}
for (int i = 3; i < 6; i++) {
f[i].assign(10000, 0);
}
for (int i = 6; i < 7; i++) {
f[i].assign(1000000, 0);
}
for (int i = 0; i < n; i++) {
int p = B[i] - 1, q = T[i] - 1, r = G[i] - 1;
f[0][p]++, f[1][q]++, f[2][r]++;
int pq = p * 100 + q, pr = p * 100 + r, qr = q * 100 + r;
int pqr = p * 10000 + q * 100 + r;
f[3][pq]++, f[4][pr]++, f[5][qr]++;
f[6][pqr]++;
}
for (int i = 0; i < 3; i++) {
for (auto &x : f[i])
ans += 1ll * x * (x - 1) / 2;
}
for (int i = 3; i < 6; i++) {
for (auto &x : f[i])
ans -= 1ll * x * (x - 1) / 2;
}
for (int i = 6; i < 7; i++) {
for (auto &x : f[i])
ans += 1ll * x * (x - 1) / 2;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |