Submission #229254

#TimeUsernameProblemLanguageResultExecution timeMemory
229254534351FunctionCup Museum (FXCUP4_museum)C++17
100 / 100
85 ms10856 KiB
#include "museum.h" #include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define SZ(x) ((int) (x).size()) #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N; int n1[3][100]; int n2[3][100][100]; int n3[100][100][100]; ll ans; ll c2(int x) { return (ll) x * (x - 1) / 2; } ll CountSimilarPairs(vi a, vi b, vi c) { N = SZ(a); FOR(i, 0, N) { int x = a[i], y = b[i], z = c[i]; x--; y--; z--; n1[0][x]++; n1[1][y]++; n1[2][z]++; n2[0][x][y]++; n2[1][y][z]++; n2[2][z][x]++; n3[x][y][z]++; } FOR(i, 0, 3) { FOR(j, 0, 100) { ans += c2(n1[i][j]); } } FOR(i, 0, 3) { FOR(j, 0, 100) { FOR(k, 0, 100) { ans -= c2(n2[i][j][k]); } } } FOR(i, 0, 100) { FOR(j, 0, 100) { FOR(k, 0, 100) { ans += c2(n3[i][j][k]); } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...