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<bits/stdc++.h>
#include "museum.h"
using namespace std;
struct vis
{
int b, t, g;
};
bool cmp1(vis a, vis b)
{
if (a.b < b.b)
return true;
else
return false;
}
bool cmp2(vis a, vis b)
{
if (a.t < b.t)
return true;
else
return false;
}
bool cmp3(vis a, vis b)
{
if (a.g < b.g)
return true;
else
return false;
}
bool cmp4(vis a, vis b)
{
if (a.b < b.b)
return true;
else if (a.b > b.b)
return false;
else if (a.t < b.t)
return true;
else
return false;
}
bool cmp5(vis a, vis b)
{
if (a.g < b.g)
return true;
else if (a.g > b.g)
return false;
else if (a.t < b.t)
return true;
else
return false;
}
bool cmp6(vis a, vis b)
{
if (a.g < b.g)
return true;
else if (a.g > b.g)
return false;
else if (a.b < b.b)
return true;
else
return false;
}
bool cmp7(vis a, vis b)
{
if (a.g < b.g)
return true;
else if (a.g > b.g)
return false;
else if (a.b < b.b)
return true;
else if (a.b > b.b)
return false;
else if (a.t < b.t)
return true;
else
return false;
}
long long CountSimilarPairs(vector<int> B, vector<int> T, vector<int> G)
{
long long N = B.size(), cnt = 0;
vector<vis> v;
for (int i = 0; i < N; i++)
v.push_back({B[i], T[i], G[i]});
sort(v.begin(), v.end(), cmp1);
for (int i = 0; i < N; )
{
int j = i;
while (j < N && v[i].b == v[j].b)
j++;
long long t = j - i;
cnt += t * (t - 1) / 2;
i = j;
}
sort(v.begin(), v.end(), cmp2);
for (int i = 0; i < N; )
{
int j = i;
while (j < N && v[i].t == v[j].t)
j++;
long long t = j - i;
cnt += t * (t - 1) / 2;
i = j;
}
sort(v.begin(), v.end(), cmp3);
for (int i = 0; i < N; )
{
int j = i;
while (j < N && v[i].g == v[j].g)
j++;
long long t = j - i;
cnt += t * (t - 1) / 2;
i = j;
}
sort(v.begin(), v.end(), cmp4);
for (int i = 0; i < N; )
{
int j = i;
while (j < N && v[i].b == v[j].b && v[i].t == v[j].t)
j++;
long long t = j - i;
cnt -= t * (t - 1) / 2;
i = j;
}
sort(v.begin(), v.end(), cmp5);
for (int i = 0; i < N; )
{
int j = i;
while (j < N && v[i].g == v[j].g && v[i].t == v[j].t)
j++;
long long t = j - i;
cnt -= t * (t - 1) / 2;
i = j;
}
sort(v.begin(), v.end(), cmp6);
for (int i = 0; i < N; )
{
int j = i;
while (j < N && v[i].g == v[j].g && v[i].b == v[j].b)
j++;
long long t = j - i;
cnt -= t * (t - 1) / 2;
i = j;
}
sort(v.begin(), v.end(), cmp7);
for (int i = 0; i < N; )
{
int j = i;
while (j < N && v[i].g == v[j].g && v[i].b == v[j].b && v[i].t == v[j].t)
j++;
long long t = j - i;
cnt += t * (t - 1) / 2;
i = j;
}
return cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |