#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
int64_t CountSimilarPairs(vector<int> A,vector<int> B,vector<int> C) {
map<int,int> a,b,c;
map<pair<int,int>,int> ab,bc,ca;
map<tuple<int,int,int>,int> abc;
int n = A.size();
ll res = 0;
for(int i = 0; i < n; i++) res += a[A[i]]++;
for(int i = 0; i < n; i++) res += b[B[i]]++;
for(int i = 0; i < n; i++) res += c[C[i]]++;
for(int i = 0; i < n; i++) res -= ab[make_pair(A[i],B[i])]++;
for(int i = 0; i < n; i++) res -= bc[make_pair(B[i],C[i])]++;
for(int i = 0; i < n; i++) res -= ca[make_pair(C[i],A[i])]++;
for(int i = 0; i < n; i++) res += abc[make_tuple(A[i],B[i],C[i])]++;
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
4 ms |
632 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
4 ms |
632 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
888 KB |
Output is correct |
11 |
Correct |
11 ms |
1656 KB |
Output is correct |
12 |
Correct |
16 ms |
1272 KB |
Output is correct |
13 |
Correct |
94 ms |
7080 KB |
Output is correct |
14 |
Correct |
149 ms |
9740 KB |
Output is correct |
15 |
Correct |
251 ms |
13552 KB |
Output is correct |
16 |
Correct |
72 ms |
6368 KB |
Output is correct |
17 |
Correct |
133 ms |
6340 KB |
Output is correct |
18 |
Correct |
281 ms |
13468 KB |
Output is correct |
19 |
Correct |
386 ms |
20036 KB |
Output is correct |
20 |
Correct |
407 ms |
20064 KB |
Output is correct |