Submission #148542

#TimeUsernameProblemLanguageResultExecution timeMemory
148542=SUM(D1:D9) (#200)FunctionCup Museum (FXCUP4_museum)C++17
0 / 100
6 ms384 KiB
#include "museum.h" long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) { long long a[20]={0, }, b[20]={0, }, c[20]={0, }, ab[300] = {0, }, bc[300] = {0,}, ac[300] = {0,}, abc[4200] = {0,}; int N = B.size(); for(int i=0; i<N; i++){ int na = B[i], nb = T[i], nc = G[i]; a[na]++, b[nb]++, c[nc]++; ab[na*15+nb]++, ac[na*15+nc]++, bc[nb*15+nc]++; abc[na*15*15 + nb*15 + nc]++; } long long ans = 0; for(int i=0; i<20; i++){ ans += (a[i] * (a[i]-1) / 2); ans += (b[i] * (b[i]-1) / 2); ans += (c[i] * (c[i]-1) / 2); } for(int i=0; i<300; i++){ ans -= (ab[i] * (ab[i]-1) / 2); ans -= (ac[i] * (ac[i]-1) / 2); ans -= (bc[i] * (bc[i]-1) / 2); } for(int i=0; i<4100; i++){ ans += (abc[i] * (abc[i]-1) / 2); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...