Submission #148452

#TimeUsernameProblemLanguageResultExecution timeMemory
148452TeamSUA (#200)FunctionCup Museum (FXCUP4_museum)C++17
100 / 100
86 ms9196 KiB
#include "museum.h" #include <bits/stdc++.h> using namespace std; long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) { int n = B.size(); typedef long long ll; ll ans = 0; vector<int> f[7]; for (int i = 0; i < 3; i++) { f[i].assign(100, 0); } for (int i = 3; i < 6; i++) { f[i].assign(10000, 0); } for (int i = 6; i < 7; i++) { f[i].assign(1000000, 0); } for (int i = 0; i < n; i++) { int p = B[i] - 1, q = T[i] - 1, r = G[i] - 1; f[0][p]++, f[1][q]++, f[2][r]++; int pq = p * 100 + q, pr = p * 100 + r, qr = q * 100 + r; int pqr = p * 10000 + q * 100 + r; f[3][pq]++, f[4][pr]++, f[5][qr]++; f[6][pqr]++; } for (int i = 0; i < 3; i++) { for (auto &x : f[i]) ans += 1ll * x * (x - 1) / 2; } for (int i = 3; i < 6; i++) { for (auto &x : f[i]) ans -= 1ll * x * (x - 1) / 2; } for (int i = 6; i < 7; i++) { for (auto &x : f[i]) ans += 1ll * x * (x - 1) / 2; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...