Submission #148420

#TimeUsernameProblemLanguageResultExecution timeMemory
148420서울대학교 연구공원 944동 삼성전자서울대연구소 (#200)FunctionCup Museum (FXCUP4_museum)C++17
100 / 100
217 ms11364 KiB
#include "museum.h" #include<bits/stdc++.h> using namespace std; template<typename T> long long s(vector<T> V) { sort(V.begin(), V.end()); int N = V.size(); long long ans = 0; int cnt = 1; for(int i=1; i<N; ++i) { if(V[i] == V[i-1]) ++cnt; else { ans += 1LL*cnt*(cnt-1)/2; cnt = 1; } } return ans + 1LL*cnt*(cnt-1)/2; } long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) { int N = B.size(); vector<tuple<int, int, int>> V; for(int i=0; i<N; ++i) V.emplace_back(B[i], T[i], G[i]); vector<pair<int, int> > X; long long os = s(B) + s(T) + s(G); X.clear(); for(int i=0; i<N; ++i) X.emplace_back(B[i], T[i]); os -= s(X); X.clear(); for(int i=0; i<N; ++i) X.emplace_back(G[i], T[i]); os -= s(X); X.clear(); for(int i=0; i<N; ++i) X.emplace_back(B[i], G[i]); os -= s(X); os += s(V); return os; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...