Submission #151009

#TimeUsernameProblemLanguageResultExecution timeMemory
151009joylintpFunctionCup Museum (FXCUP4_museum)C++17
100 / 100
235 ms8936 KiB
#include<bits/stdc++.h> #include "museum.h" using namespace std; struct vis { int b, t, g; }; bool cmp1(vis a, vis b) { if (a.b < b.b) return true; else return false; } bool cmp2(vis a, vis b) { if (a.t < b.t) return true; else return false; } bool cmp3(vis a, vis b) { if (a.g < b.g) return true; else return false; } bool cmp4(vis a, vis b) { if (a.b < b.b) return true; else if (a.b > b.b) return false; else if (a.t < b.t) return true; else return false; } bool cmp5(vis a, vis b) { if (a.g < b.g) return true; else if (a.g > b.g) return false; else if (a.t < b.t) return true; else return false; } bool cmp6(vis a, vis b) { if (a.g < b.g) return true; else if (a.g > b.g) return false; else if (a.b < b.b) return true; else return false; } bool cmp7(vis a, vis b) { if (a.g < b.g) return true; else if (a.g > b.g) return false; else if (a.b < b.b) return true; else if (a.b > b.b) return false; else if (a.t < b.t) return true; else return false; } long long CountSimilarPairs(vector<int> B, vector<int> T, vector<int> G) { long long N = B.size(), cnt = 0; vector<vis> v; for (int i = 0; i < N; i++) v.push_back({B[i], T[i], G[i]}); sort(v.begin(), v.end(), cmp1); for (int i = 0; i < N; ) { int j = i; while (j < N && v[i].b == v[j].b) j++; long long t = j - i; cnt += t * (t - 1) / 2; i = j; } sort(v.begin(), v.end(), cmp2); for (int i = 0; i < N; ) { int j = i; while (j < N && v[i].t == v[j].t) j++; long long t = j - i; cnt += t * (t - 1) / 2; i = j; } sort(v.begin(), v.end(), cmp3); for (int i = 0; i < N; ) { int j = i; while (j < N && v[i].g == v[j].g) j++; long long t = j - i; cnt += t * (t - 1) / 2; i = j; } sort(v.begin(), v.end(), cmp4); for (int i = 0; i < N; ) { int j = i; while (j < N && v[i].b == v[j].b && v[i].t == v[j].t) j++; long long t = j - i; cnt -= t * (t - 1) / 2; i = j; } sort(v.begin(), v.end(), cmp5); for (int i = 0; i < N; ) { int j = i; while (j < N && v[i].g == v[j].g && v[i].t == v[j].t) j++; long long t = j - i; cnt -= t * (t - 1) / 2; i = j; } sort(v.begin(), v.end(), cmp6); for (int i = 0; i < N; ) { int j = i; while (j < N && v[i].g == v[j].g && v[i].b == v[j].b) j++; long long t = j - i; cnt -= t * (t - 1) / 2; i = j; } sort(v.begin(), v.end(), cmp7); for (int i = 0; i < N; ) { int j = i; while (j < N && v[i].g == v[j].g && v[i].b == v[j].b && v[i].t == v[j].t) j++; long long t = j - i; cnt += t * (t - 1) / 2; i = j; } return cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...