#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; )
{
int 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 |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 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 |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
512 KB |
Output is correct |
11 |
Correct |
8 ms |
896 KB |
Output is correct |
12 |
Correct |
28 ms |
3200 KB |
Output is correct |
13 |
Correct |
77 ms |
5748 KB |
Output is correct |
14 |
Correct |
105 ms |
8336 KB |
Output is correct |
15 |
Correct |
162 ms |
12016 KB |
Output is correct |
16 |
Incorrect |
157 ms |
18756 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |