This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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);
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |