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 <string.h>
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
static int a[100],b[100][100],c[100][100][100];
int n = B.size();
long long ans=0;
for(int i=0;i<n;i++)B[i]--,T[i]--,G[i]--;
memset(a,0,sizeof(a));
for(int i=0;i<n;i++)a[B[i]]++;
for(int i=0;i<100;i++)ans+=1LL*a[i]*(a[i]-1)/2;
memset(a,0,sizeof(a));
for(int i=0;i<n;i++)a[T[i]]++;
for(int i=0;i<100;i++)ans+=1LL*a[i]*(a[i]-1)/2;
memset(a,0,sizeof(a));
for(int i=0;i<n;i++)a[G[i]]++;
for(int i=0;i<100;i++)ans+=1LL*a[i]*(a[i]-1)/2;
memset(b,0,sizeof(b));
for(int i=0;i<n;i++)b[B[i]][T[i]]++;
for(int i=0;i<100;i++)for(int j=0;j<100;j++)ans-=1LL*b[i][j]*(b[i][j]-1)/2;
memset(b,0,sizeof(b));
for(int i=0;i<n;i++)b[G[i]][T[i]]++;
for(int i=0;i<100;i++)for(int j=0;j<100;j++)ans-=1LL*b[i][j]*(b[i][j]-1)/2;
memset(b,0,sizeof(b));
for(int i=0;i<n;i++)b[B[i]][G[i]]++;
for(int i=0;i<100;i++)for(int j=0;j<100;j++)ans-=1LL*b[i][j]*(b[i][j]-1)/2;
memset(c,0,sizeof(c));
for(int i=0;i<n;i++)c[B[i]][T[i]][G[i]]++;
for(int i=0;i<100;i++)for(int j=0;j<100;j++)for(int k=0;k<100;k++)ans+=1LL*c[i][j][k]*(c[i][j][k]-1)/2;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |