#include "museum.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int ma[3][111];
int freq[3][111][111];
int s[111][111][111];
ll c(ll n)
{
return (n*(n-1))/2;
}
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G)
{
int n = B.size();
for(int i=0;i<n;i++)
{
ma[0][B[i]]++;
ma[1][T[i]]++;
ma[2][G[i]]++;
freq[0][T[i]][G[i]]++;
freq[1][G[i]][B[i]]++;
freq[2][B[i]][T[i]]++;
s[B[i]][T[i]][G[i]]++;
}
ll ans = 0;
for(int i=0;i<102;i++)
{
for(int j=0;j<3;j++)
{
ans+=c(ma[j][i]);
}
}
for(int a=0;a<3;a++)
{
for(int i=0;i<102;i++)
{
for(int j=0;j<102;j++)
{
ans-=c(freq[a][i][j]);
}
}
}
for(int i=0;i<102;i++)
{
for(int j=0;j<102;j++)
{
for(int k=0;k<102;k++)
{
ans+=c(s[i][j][k]);
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
512 KB |
Output is correct |
3 |
Correct |
7 ms |
512 KB |
Output is correct |
4 |
Correct |
8 ms |
640 KB |
Output is correct |
5 |
Correct |
8 ms |
1792 KB |
Output is correct |
6 |
Correct |
10 ms |
2304 KB |
Output is correct |
7 |
Correct |
10 ms |
3200 KB |
Output is correct |
8 |
Correct |
9 ms |
512 KB |
Output is correct |
9 |
Correct |
10 ms |
4352 KB |
Output is correct |
10 |
Correct |
10 ms |
4352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
512 KB |
Output is correct |
3 |
Correct |
7 ms |
512 KB |
Output is correct |
4 |
Correct |
8 ms |
640 KB |
Output is correct |
5 |
Correct |
8 ms |
1792 KB |
Output is correct |
6 |
Correct |
10 ms |
2304 KB |
Output is correct |
7 |
Correct |
10 ms |
3200 KB |
Output is correct |
8 |
Correct |
9 ms |
512 KB |
Output is correct |
9 |
Correct |
10 ms |
4352 KB |
Output is correct |
10 |
Correct |
10 ms |
4352 KB |
Output is correct |
11 |
Correct |
12 ms |
5248 KB |
Output is correct |
12 |
Correct |
19 ms |
1152 KB |
Output is correct |
13 |
Correct |
31 ms |
5876 KB |
Output is correct |
14 |
Correct |
41 ms |
7280 KB |
Output is correct |
15 |
Correct |
59 ms |
8304 KB |
Output is correct |
16 |
Correct |
77 ms |
5228 KB |
Output is correct |
17 |
Correct |
81 ms |
5324 KB |
Output is correct |
18 |
Correct |
90 ms |
6628 KB |
Output is correct |
19 |
Correct |
87 ms |
10092 KB |
Output is correct |
20 |
Correct |
93 ms |
10084 KB |
Output is correct |