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++) {
aa[--a[i]].push_back(i);
bb[--b[i]].push_back(i);
cc[--c[i]].push_back(i);
}
ll ans = 0;
for (int i = 0; i < 100; i++) {
int c1 = 0;
vector<int> tm[100], tb[100];
// ��ġ�� �ֵ� �߿�...
// ���ο� b�迭�� �ٽ� �Ѹ���??
for (int t : aa[i]) {
ch[t]++;
c1++;
tm[b[t]].push_back(t);
tb[c[t]].push_back(t);
}
ans += (c1) * (c1 - 1LL) / 2;
for (int j = 0; j < 100; j++) {
vector<int> ttm[100];
int c2 = 0;
for (int t : tm[j]) {
if (ch[t]) {
ca[t]++;
c2++;
ttm[c[t]].push_back(t);
}
}
ans -= (c2) * (c2 - 1LL) / 2;
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : ttm[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 : tm[j]) {
if (ch[t])
ca[t]--;
}
}
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : tb[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++) {
vector<int> tm[100];
int c2 = 0;
for (int t : bb[j]) {
ca[t]++;
c2++;
tm[c[t]].push_back(t);
}
ans += (c2) * (c2 - 1LL) / 2;
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : tm[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:107: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... |