Submission #151458

#TimeUsernameProblemLanguageResultExecution timeMemory
151458AlexPop28FunctionCup Museum (FXCUP4_museum)C++17
100 / 100
321 ms16788 KiB
#include <bits/stdc++.h> #include "museum.h" using namespace std; const int BASE = 101; long long Count(const vector<int> &v) { map<int, int> freq; for (auto &x : v) ++freq[x]; long long ans = 0LL; for (auto &p : freq) ans += 1LL * p.second * (p.second - 1) / 2LL; return ans; } vector<int> Make(const vector<int> &a, const vector<int> &b) { vector<int> ret(a.size()); for (int i = 0; i < (int)a.size(); ++i) { ret[i] = a[i] * BASE + b[i]; } return ret; } long long CountSimilarPairs(vector<int> B, vector<int> T, vector<int> G) { long long ans = 0LL; ans += Count(B); ans += Count(T); ans += Count(G); ans -= Count(Make(B, T)); ans -= Count(Make(B, G)); ans -= Count(Make(T, G)); ans += Count(Make(Make(B, T), G)); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...