Submission #148820

#TimeUsernameProblemLanguageResultExecution timeMemory
148820From The Sky (#200)FunctionCup Museum (FXCUP4_museum)C++17
100 / 100
137 ms7532 KiB
#include "museum.h" #pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef vector<int> vi; typedef long long ll; #define f first #define s second #define pb push_back #define lb lower_bound #define ub upper_bound #define sz(x) (int)x.size() #define all(x) begin(x), end(x) #define rsz resize const int md = 1e9+7; const ll inf = 1e18; const int maxn = 105; template<class T> void ckmin(T &a, T b) { a = min(a, b); } template<class T> void ckmax(T &a, T b) { a = max(a, b); } vector< ii > goat[maxn]; int mem[maxn][maxn]; long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) { int n = B.size(); for(int i = 0; i< n; i++) { int x = B[i], y = T[i], z = G[i]; goat[x].pb(ii(y, z)); } ll res = 0; for(int i = 1; i<= 100; i++) { int k = sz(goat[i]); res += 1LL*k*(k-1)/2; for(ii kk : goat[i]) { int x = kk.f, y = kk.s; for(int j = 1; j<= 100; j++) { if(j == x) continue; res += mem[j][y]; } for(int j = 1; j<= 100; j++) { if(j == y) continue; res += mem[x][j]; } res += mem[x][y]; } for(ii kk : goat[i]) { int x = kk.f, y = kk.s; mem[x][y]++; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...