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"
long long cnt1[101],cnt2[101][101],cnt3[101][101][101];
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int N = B.size();
long long ret=0;
for(auto i:B) cnt1[i]++;
for(int i=1;i<=100;i++){
ret = ret+cnt1[i]*(cnt1[i]-1)/2;
cnt1[i]=0;
}
for(auto i:T) cnt1[i]++;
for(int i=1;i<=100;i++){
ret = ret+cnt1[i]*(cnt1[i]-1)/2;
cnt1[i]=0;
}
for(auto i:G) cnt1[i]++;
for(int i=1;i<=100;i++){
ret = ret+cnt1[i]*(cnt1[i]-1)/2;
cnt1[i]=0;
}
for(int i=0;i<N;i++) cnt2[B[i]][T[i]]++;
for(int i=1;i<=100;i++){
for(int j=1;j<=100;j++){
ret = ret-cnt2[i][j]*(cnt2[i][j]-1)/2;
cnt2[i][j]=0;
}
}
for(int i=0;i<N;i++) cnt2[B[i]][G[i]]++;
for(int i=1;i<=100;i++){
for(int j=1;j<=100;j++){
ret = ret-cnt2[i][j]*(cnt2[i][j]-1)/2;
cnt2[i][j]=0;
}
}
for(int i=0;i<N;i++) cnt2[T[i]][G[i]]++;
for(int i=1;i<=100;i++){
for(int j=1;j<=100;j++){
ret = ret-cnt2[i][j]*(cnt2[i][j]-1)/2;
cnt2[i][j]=0;
}
}
for(int i=0;i<N;i++){
cnt3[B[i]][T[i]][G[i]]++;
}
for(int i=1;i<=100;i++){
for(int j=1;j<=100;j++){
for(int k=1;k<=100;k++){
ret = ret+cnt3[i][j][k]*(cnt3[i][j][k]-1)/2;
}
}
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |