#include <bits/stdc++.h>
#include "museum.h"
using namespace std;
typedef long long ll;
ll CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int n = (int)B.size();
map<int, int> b, t, g;
map<pair<int, int>, int> bt, tg, gb;
map<pair<pair<int, int>, int>, int> btg;
ll ret = 0;
for (int i = 0; i < n; i++)
ret += b[B[i]]++;
for (int i = 0; i < n; i++)
ret += t[T[i]]++;
for (int i = 0; i < n; i++)
ret += g[G[i]]++;
for (int i = 0; i < n; i++)
ret -= bt[{B[i], T[i]}]++;
for (int i = 0; i < n; i++)
ret -= tg[{T[i], G[i]}]++;
for (int i = 0; i < n; i++)
ret -= gb[{G[i], B[i]}]++;
for (int i = 0; i < n; i++)
ret += btg[{ {B[i], T[i]}, G[i]}]++;
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
824 KB |
Output is correct |
10 |
Correct |
3 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
824 KB |
Output is correct |
10 |
Correct |
3 ms |
724 KB |
Output is correct |
11 |
Correct |
6 ms |
1620 KB |
Output is correct |
12 |
Correct |
14 ms |
1128 KB |
Output is correct |
13 |
Correct |
57 ms |
6864 KB |
Output is correct |
14 |
Correct |
90 ms |
9684 KB |
Output is correct |
15 |
Correct |
123 ms |
13356 KB |
Output is correct |
16 |
Correct |
56 ms |
6212 KB |
Output is correct |
17 |
Correct |
94 ms |
6368 KB |
Output is correct |
18 |
Correct |
161 ms |
13320 KB |
Output is correct |
19 |
Correct |
227 ms |
19916 KB |
Output is correct |
20 |
Correct |
211 ms |
19980 KB |
Output is correct |