Submission #148388

#TimeUsernameProblemLanguageResultExecution timeMemory
148388USA1 (#200)FunctionCup Museum (FXCUP4_museum)C++17
100 / 100
392 ms25840 KiB
#include "museum.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll s1(vector<int> A){ map<int, ll> freq; for(int x : A){ freq[x]++; } ll ans = 0; for(auto r : freq){ ans += r.second * r.second; } return ans; } ll s2(vector<int> A, vector<int> B){ map<int, ll> freq; for(int i = 0; i < (int)A.size(); i++){ freq[A[i] + B[i] * 200]++; } ll ans = 0; for(auto r : freq){ ans += r.second * r.second; } return ans; } ll s3(vector<int> A, vector<int> B, vector<int> C){ map<int, ll> freq; for(int i = 0; i < (int)A.size(); i++){ freq[A[i] + B[i] * 200 + C[i] * 40000]++; } ll ans = 0; for(auto r : freq){ ans += r.second * r.second; } return ans; } long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) { using namespace std; ll ans = s1(B) + s1(T) + s1(G) - s2(B, T) - s2(B, G) - s2(T, G) + s3(B, T, G); return (ans - (int)B.size()) / 2; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...