제출 #148428

#제출 시각아이디문제언어결과실행 시간메모리
148428모현보유국 (#200)함수컵 박물관 (FXCUP4_museum)C++17
100 / 100
435 ms19300 KiB
#include "museum.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p; typedef pair<p, ll> pp; map<ll, ll> aa; map<p, ll> bb; map<pp, ll> cc; long long CountSimilarPairs(std::vector<int> a, std::vector<int> b, std::vector<int> c) { int n = b.size(); ll ans = 0; //A for(int i=0; i<n; i++){ aa[a[i]]++; } for(auto i : aa){ ans += i.second * (i.second - 1) / 2; } aa.clear(); //B for(int i=0; i<n; i++){ aa[b[i]]++; } for(auto i : aa){ ans += i.second * (i.second - 1) / 2; } aa.clear(); //C for(int i=0; i<n; i++){ aa[c[i]]++; } for(auto i : aa){ ans += i.second * (i.second - 1) / 2; } aa.clear(); //AB for(int i=0; i<n; i++){ p now = make_pair(a[i], b[i]); bb[now]++; } for(auto i : bb){ ans -= i.second * (i.second - 1) / 2; } bb.clear(); //BC for(int i=0; i<n; i++){ p now = make_pair(b[i], c[i]); bb[now]++; } for(auto i : bb){ ans -= i.second * (i.second - 1) / 2; } bb.clear(); //CA for(int i=0; i<n; i++){ p now = make_pair(c[i], a[i]); bb[now]++; } for(auto i : bb){ ans -= i.second * (i.second - 1) / 2; } bb.clear(); //ABC for(int i=0; i<n; i++){ p tmp = make_pair(a[i], b[i]); pp now = make_pair(tmp, c[i]); cc[now]++; } for(auto i : cc){ ans += i.second * (i.second - 1) / 2; } cc.clear(); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...