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 <cstring>
#include <vector>
int cnt1[101],cnt2[101][101], cnt3[101][101][101];
long long Solve(const std::vector< int > &A)
{
memset(cnt1,0,sizeof(cnt1));
for (int x : A)
++cnt1[x];
long long res = 0;
for (int i = 1; i <= 100; ++i)
res+=1ll*cnt1[i] *(cnt1[i]-1) /2;
return res;
}
long long Solve2(const std::vector< int > &A, const std::vector< int > &B) {
memset(cnt2, 0, sizeof(cnt2));
for (int i = 0; i < A.size(); ++ i)
++cnt2[A[i]][B[i]];
long long res = 0;
for (int i = 1; i <= 100; ++i)
for (int j = 0; j <= 100; ++j)
res+=1ll*cnt2[i][j]*(cnt2[i][j]-1)/2;
return res;
}
long long Solve3(const std::vector< int > &A, const std::vector< int > &B, const std::vector< int > &C) {
memset(cnt3, 0, sizeof(cnt3));
for (int i = 0; i < A.size(); ++ i)
++cnt3[A[i]][B[i]][C[i]];
long long res = 0;
for (int i = 1; i <= 100; ++i)
for (int j = 0; j <= 100; ++j)
for (int k = 0; k <= 100; ++k)
res+=1ll*cnt3[i][j][k]*(cnt3[i][j][k]-1)/2;
return res;
}
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int N = B.size();
return(Solve(B) + Solve(T) + Solve(G) - Solve2(B, T) - Solve2(B, G) - Solve2(T, G)
+Solve3(B, T, G));
}
Compilation message (stderr)
museum.cpp: In function 'long long int Solve2(const std::vector<int>&, const std::vector<int>&)':
museum.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < A.size(); ++ i)
~~^~~~~~~~~~
museum.cpp: In function 'long long int Solve3(const std::vector<int>&, const std::vector<int>&, const std::vector<int>&)':
museum.cpp:26:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < A.size(); ++ i)
~~^~~~~~~~~~
museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:36:6: warning: unused variable 'N' [-Wunused-variable]
int N = B.size();
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |