이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |