#include "museum.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<p, ll> pp;
map<ll, ll> aa;
map<p, ll> bb;
map<pp, ll> cc;
long long CountSimilarPairs(std::vector<int> a, std::vector<int> b, std::vector<int> c) {
int n = b.size();
ll ans = 0;
//A
for(int i=0; i<n; i++){
aa[a[i]]++;
}
for(auto i : aa){
ans += i.second * (i.second - 1) / 2;
}
aa.clear();
//B
for(int i=0; i<n; i++){
aa[b[i]]++;
}
for(auto i : aa){
ans += i.second * (i.second - 1) / 2;
}
aa.clear();
//C
for(int i=0; i<n; i++){
aa[c[i]]++;
}
for(auto i : aa){
ans += i.second * (i.second - 1) / 2;
}
aa.clear();
//AB
for(int i=0; i<n; i++){
p now = make_pair(a[i], b[i]);
bb[now]++;
}
for(auto i : bb){
ans -= i.second * (i.second - 1) / 2;
}
bb.clear();
//BC
for(int i=0; i<n; i++){
p now = make_pair(b[i], c[i]);
bb[now]++;
}
for(auto i : bb){
ans -= i.second * (i.second - 1) / 2;
}
bb.clear();
//CA
for(int i=0; i<n; i++){
p now = make_pair(c[i], a[i]);
bb[now]++;
}
for(auto i : bb){
ans -= i.second * (i.second - 1) / 2;
}
bb.clear();
//ABC
for(int i=0; i<n; i++){
p tmp = make_pair(a[i], b[i]);
pp now = make_pair(tmp, c[i]);
cc[now]++;
}
for(auto i : cc){
ans += i.second * (i.second - 1) / 2;
}
cc.clear();
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 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 |
7 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 |
9 ms |
640 KB |
Output is correct |
10 |
Correct |
9 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 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 |
7 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 |
9 ms |
640 KB |
Output is correct |
10 |
Correct |
9 ms |
512 KB |
Output is correct |
11 |
Correct |
14 ms |
896 KB |
Output is correct |
12 |
Correct |
21 ms |
1152 KB |
Output is correct |
13 |
Correct |
96 ms |
5876 KB |
Output is correct |
14 |
Correct |
148 ms |
8432 KB |
Output is correct |
15 |
Correct |
234 ms |
12388 KB |
Output is correct |
16 |
Correct |
80 ms |
5220 KB |
Output is correct |
17 |
Correct |
141 ms |
5220 KB |
Output is correct |
18 |
Correct |
303 ms |
12900 KB |
Output is correct |
19 |
Correct |
431 ms |
19300 KB |
Output is correct |
20 |
Correct |
435 ms |
19300 KB |
Output is correct |