Submission #150993

#TimeUsernameProblemLanguageResultExecution timeMemory
150993pichuliaFunctionCup Museum (FXCUP4_museum)C++17
100 / 100
81 ms11108 KiB
#include "museum.h" #include<vector> #include<algorithm> using namespace std; int a[102]; int b[102]; int c[102]; int ab[102][102]; int bc[102][102]; int ca[102][102]; int abc[102][102][102]; long long cal(int x) { long long int res = x; return res * (res - 1) / 2; } long long CountSimilarPairs(std::vector<int> x, std::vector<int> y, std::vector<int> z) { int n = x.size(); long long int res = 0; int i, j, k; for (i = 0; i < n; i++) { a[x[i]]++; b[y[i]]++; c[z[i]]++; ab[x[i]][y[i]]++; bc[y[i]][z[i]]++; ca[z[i]][x[i]]++; abc[x[i]][y[i]][z[i]]++; } for (i = 1; i <= 100; i++) { res += cal(a[i]); res += cal(b[i]); res += cal(c[i]); for (j = 1; j <= 100; j++) { res -= cal(ab[i][j]); res -= cal(bc[i][j]); res -= cal(ca[i][j]); for (k = 1; k <= 100; k++) { res += cal(abc[i][j][k]); } } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...