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<bits/stdc++.h>
#include"museum.h"
using namespace std;
int ac[200001];
bool cmp(int a, int b)
{
return ac[a] < ac[b];
}
long long CountSimilarPairs(vector<int> B, vector<int> T, vector<int> G)
{
int n = B.size();
vector<int> id(n);
vector<vector<int>> v(n);
for (int i = 0; i < n; i++)
v[i].resize(3), id[i] = i, v[i][0] = B[i], v[i][1] = T[i], v[i][2] = G[i];
long long val[8] = {};
for (int ag = 1; ag <= 7; ag++)
{
for (int i = 0; i < n; i++)
{
ac[i] = 0;
int t = ag;
for (int j = 0; j < 3; j++, t /= 2)
ac[i] = ac[i] * 100 + (v[i][j] - 1) * (t & 1);
}
sort(id.begin(), id.end(), cmp);
for (int i = 0; i < n; )
{
long long cnt = 1;
while (i + 1 < n && ac[id[i]] == ac[id[i + 1]])
cnt++, i++;
val[ag] += cnt * (cnt - 1) / 2, i++;
}
}
return (val[1] + val[2] + val[4] - val[3] - val[5] - val[6] + val[7]);
return 0;
}
// * * ***** * * * * **** **** **** ** **
// * * * ** * * * * * * * * * * *
// ***** ***** * * * * * * **** * * * *
// * * * * ** * * * * * * ***** *
// * * ***** * * *** **** * * **** * *****
// ***** ***** * * * ***** * * ***** *****
// * * * * * * * ** * * * *
// * * * ***** * * * * * * *****
// * * * * * * * * ** * *
// **** ***** * ***** ***** * * * *
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |