This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "museum.h"
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdb;
typedef tuple<int,int,int,int> TP;
typedef vector<vector<ll>> mat;
const int N=105;
const ll mod=1e9+7;
int n;
ll ans,b[N],t[N],g[N],bt[N][N],tg[N][N],bg[N][N],btg[N][N][N];
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
n=B.size();
for(int i=0;i<n;i++){
b[B[i]]++; t[T[i]]++; g[G[i]]++;
bt[B[i]][T[i]]++; tg[T[i]][G[i]]++; bg[B[i]][G[i]]++;
btg[B[i]][T[i]][G[i]]++;
}
for(int i=1;i<=100;i++){
ans+=b[i]*(b[i]-1LL)/2LL;
ans+=g[i]*(g[i]-1LL)/2LL;
ans+=t[i]*(t[i]-1LL)/2LL;
}
for(int i=1;i<=100;i++) for(int j=1;j<=100;j++){
ans-=bt[i][j]*(bt[i][j]-1LL)/2LL;
ans-=tg[i][j]*(tg[i][j]-1LL)/2LL;
ans-=bg[i][j]*(bg[i][j]-1LL)/2LL;
}
for(int i=1;i<=100;i++) for(int j=1;j<=100;j++) for(int k=1;k<=100;k++){
ans+=btg[i][j][k]*(btg[i][j][k]-1LL);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |