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>
using namespace std;
int n;
long long cnt[105],cnt2[30005],cnt3[5000005];
long long da1(vector <int> xx)
{
long long ans = 0;
for(int i : xx) cnt[i]++;
for(int i = 1;i <= 100;i++) ans += cnt[i]*(cnt[i]-1)/2;
memset(cnt,0,sizeof(cnt));
return ans;
}
long long da2(vector <int> xx,vector <int> yy)
{
long long ans = 0;
for(int i = 0;i < n;i++) cnt2[xx[i]*200+yy[i]]++;
for(int i = 1;i <= 30000;i++) ans += cnt2[i]*(cnt2[i]-1)/2;
memset(cnt2,0,sizeof(cnt2));
return ans;
}
long long da3(vector <int> xx,vector <int> yy,vector <int> zz)
{
long long ans = 0;
for(int i = 0;i < n;i++) cnt3[xx[i]*40000+yy[i]*200+zz[i]]++;
for(int i = 1;i <= 5000000;i++) ans += cnt3[i]*(cnt3[i]-1)/2;
memset(cnt3,0,sizeof(cnt3));
return ans;
}
long long CountSimilarPairs(vector<int> a1,vector<int> a2,vector<int> a3) {
long long ans = 0;
n = a1.size();
ans = da1(a1)+da1(a2)+da1(a3);
ans -= da2(a1,a2)+da2(a2,a3)+da2(a3,a1);
ans += da3(a1,a2,a3);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |