#include "museum.h"
#include <map>
using namespace std;
typedef long long ll;
const int MX = 101;
ll BC[MX], TC[MX], GC[MX];
map<pair<int, int>, ll> BT, BG, TG;
map<tuple<int, int, int>, ll> BTG;
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int N = B.size();
long long ans = 0;
for(int i=0; i<N; i++){
int b = B[i], t = T[i], g = G[i];
BC[b]++, TC[t]++, GC[g]++;
BT[{b,t}]++, BG[{b,g}]++, TG[{t,g}]++;
BTG[{b,t,g}]++;
}
for(int i=0; i<MX; i++){
ans+= BC[i] * (BC[i]-1);
ans+= TC[i] * (TC[i]-1);
ans+= GC[i] * (GC[i]-1);
}
for(auto [p,cnt]: BT) ans-= cnt*(cnt-1);
for(auto [p,cnt]: BG) ans-= cnt*(cnt-1);
for(auto [p,cnt]: TG) ans-= cnt*(cnt-1);
for(auto [p,cnt]: BTG) ans+= cnt*(cnt-1);
return ans/2;
}
Compilation message
museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:25:17: warning: unused variable 'p' [-Wunused-variable]
for(auto [p,cnt]: BT) ans-= cnt*(cnt-1);
^
museum.cpp:26:17: warning: unused variable 'p' [-Wunused-variable]
for(auto [p,cnt]: BG) ans-= cnt*(cnt-1);
^
museum.cpp:27:17: warning: unused variable 'p' [-Wunused-variable]
for(auto [p,cnt]: TG) ans-= cnt*(cnt-1);
^
museum.cpp:28:17: warning: unused variable 'p' [-Wunused-variable]
for(auto [p,cnt]: BTG) ans+= cnt*(cnt-1);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
352 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
604 KB |
Output is correct |
8 |
Correct |
3 ms |
476 KB |
Output is correct |
9 |
Correct |
5 ms |
804 KB |
Output is correct |
10 |
Correct |
5 ms |
888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
352 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
604 KB |
Output is correct |
8 |
Correct |
3 ms |
476 KB |
Output is correct |
9 |
Correct |
5 ms |
804 KB |
Output is correct |
10 |
Correct |
5 ms |
888 KB |
Output is correct |
11 |
Correct |
12 ms |
1588 KB |
Output is correct |
12 |
Correct |
13 ms |
1252 KB |
Output is correct |
13 |
Correct |
104 ms |
7032 KB |
Output is correct |
14 |
Correct |
170 ms |
9748 KB |
Output is correct |
15 |
Correct |
263 ms |
13460 KB |
Output is correct |
16 |
Correct |
64 ms |
6300 KB |
Output is correct |
17 |
Correct |
115 ms |
6396 KB |
Output is correct |
18 |
Correct |
315 ms |
13424 KB |
Output is correct |
19 |
Correct |
461 ms |
19932 KB |
Output is correct |
20 |
Correct |
470 ms |
20040 KB |
Output is correct |