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"
using namespace std;
typedef long long ll;
char ch[200000];
char ca[200000];
vector<int> aa[100], bb[100], cc[100];
long long CountSimilarPairs(std::vector<int> a, std::vector<int> b, std::vector<int> c) {
int n = a.size();
for (int i = 0; i < n; i++) {
a[i]--;
aa[a[i]].push_back(i);
b[i]--;
bb[b[i]].push_back(i);
c[i]--;
cc[c[i]].push_back(i);
}
ll ans = 0;
for (int i = 0; i < 100; i++) {
int c1 = 0;
for (int t : aa[i]) {
ch[t]++;
c1++;
}
ans += (c1) * (c1 - 1LL) / 2;
for (int j = 0; j < 100; j++) {
int c2 = 0;
for (int t : bb[j]) {
if (ch[t]) {
ca[t]++;
c2++;
}
}
ans -= (c2) * (c2 - 1LL) / 2;
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : cc[k]) {
if (ca[t])
c3++;
}
ans += (c3) * (c3 - 1LL) / 2;
// if (i == 0 && j == 0 && k== 0) printf("%lld : %d %d %d\n", ans, c1, c2, c3);
}
for (int t : bb[j]) {
if (ch[t])
ca[t]--;
}
}
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : cc[k]) {
if (ch[t])
c3++;
}
ans -= (c3) * (c3 - 1LL) / 2;
}
for (int t : aa[i])
ch[t]--;
}
// 2��°���� ��ġ�� ��.
for (int j = 0; j < 100; j++) {
int c2 = 0;
for (int t : bb[j]) {
ca[t]++;
c2++;
}
ans += (c2) * (c2 - 1LL) / 2;
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : cc[k]) {
if (ca[t])
c3++;
}
ans -= (c3) * (c3 - 1LL) / 2;
// if (i == 0 && j == 0 && k== 0) printf("%lld : %d %d %d\n", ans, c1, c2, c3);
}
for (int t : bb[j]) {
ca[t]--;
}
}
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : cc[k]) {
c3++;
}
ans += (c3) * (c3 - 1LL) / 2;
// if (i == 0 && j == 0 && k== 0) printf("%lld : %d %d %d\n", ans, c1, c2, c3);
}
return ans;
}
Compilation message (stderr)
museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:102:12: warning: unused variable 't' [-Wunused-variable]
for (int t : cc[k]) {
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |