#include "museum.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template<typename T>
ll f(vector<T> v) {
map<T, int> s;
for(auto x : v) s[x] += 1;
ll r = 0;
for(auto p : s) {
ll t = p.second;
r += (t * (t - 1)) / 2;
}
return r;
}
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int N = B.size();
ll r = 0;
r += f(B);
r += f(T);
r += f(G);
vector<int> BT, TG, BG, BTG;
for(int i=0; i<N; i++) {
BT.push_back(B[i]*1000 + T[i]);
TG.push_back(T[i]*1000 + G[i]);
BG.push_back(B[i]*1000 + G[i]);
BTG.push_back(B[i]*1000000 + T[i]*1000 + G[i]);
}
r -= f(BT);
r -= f(TG);
r -= f(BG);
r += f(BTG);
return r;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
432 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
7 ms |
512 KB |
Output is correct |
8 |
Correct |
7 ms |
512 KB |
Output is correct |
9 |
Correct |
8 ms |
512 KB |
Output is correct |
10 |
Correct |
9 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
432 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
7 ms |
512 KB |
Output is correct |
8 |
Correct |
7 ms |
512 KB |
Output is correct |
9 |
Correct |
8 ms |
512 KB |
Output is correct |
10 |
Correct |
9 ms |
512 KB |
Output is correct |
11 |
Correct |
14 ms |
896 KB |
Output is correct |
12 |
Correct |
23 ms |
1920 KB |
Output is correct |
13 |
Correct |
82 ms |
5400 KB |
Output is correct |
14 |
Correct |
128 ms |
7728 KB |
Output is correct |
15 |
Correct |
188 ms |
11144 KB |
Output is correct |
16 |
Correct |
86 ms |
10588 KB |
Output is correct |
17 |
Correct |
141 ms |
10588 KB |
Output is correct |
18 |
Correct |
238 ms |
13964 KB |
Output is correct |
19 |
Correct |
362 ms |
17744 KB |
Output is correct |
20 |
Correct |
355 ms |
17620 KB |
Output is correct |