#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;
}
// * * ***** * * * * **** **** **** ** **
// * * * ** * * * * * * * * * * *
// ***** ***** * * * * * * **** * * * *
// * * * * ** * * * * * * ***** *
// * * ***** * * *** **** * * **** * *****
// ***** ***** * * * ***** * * ***** *****
// * * * * * * * ** * * * *
// * * * ***** * * * * * * *****
// * * * * * * * * ** * *
// **** ***** * ***** ***** * * * *
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
512 KB |
Output is correct |
11 |
Correct |
7 ms |
768 KB |
Output is correct |
12 |
Correct |
24 ms |
3072 KB |
Output is correct |
13 |
Correct |
74 ms |
5108 KB |
Output is correct |
14 |
Correct |
103 ms |
7416 KB |
Output is correct |
15 |
Correct |
162 ms |
10992 KB |
Output is correct |
16 |
Correct |
134 ms |
17516 KB |
Output is correct |
17 |
Correct |
216 ms |
18908 KB |
Output is correct |
18 |
Correct |
261 ms |
19172 KB |
Output is correct |
19 |
Correct |
274 ms |
19308 KB |
Output is correct |
20 |
Correct |
274 ms |
19300 KB |
Output is correct |