#include "museum.h"
#include <vector>
#include <set>
using namespace std;
using ll = long long;
int arr1[101];
int arr2[101];
int arr3[101];
ll fac[101];
ll CountSimilarPairs(vector<int> B, vector<int> T, vector<int> G)
{
fac[0] = 1;
for (int i = 1; i < 101; i++)
fac[i] = fac[i - 1] * i;
ll ans = 0;
int n = (int)B.size();
for (int i = 0; i < n; i++)
arr1[B[i]]++;
for (int i = 0; i < n; i++)
arr2[T[i]]++;
for (int i = 0; i < n; i++)
arr3[G[i]]++;
for (int i = 0; i < 101; i++)
if (arr1[i] > 1)
ans += fac[arr1[i]] / 2;
for (int i = 0; i < 101; i++)
if (arr2[i] > 1)
ans += fac[arr2[i]] / 2;
for (int i = 0; i < 101; i++)
if (arr3[i] > 1)
ans += fac[arr3[i]] / 2;
set<pair<int, int>> s;
for (int i = 0; i < n; i++)
s.insert({ B[i], T[i] });
ans -= fac[n - (int)s.size() + 1] / 2;
s.clear();
for (int i = 0; i < n; i++)
s.insert({ G[i], T[i] });
ans -= fac[n - (int)s.size() + 1] / 2;
s.clear();
for (int i = 0; i < n; i++)
s.insert({ B[i], G[i] });
ans -= fac[n - (int)s.size() + 1] / 2;
set<pair<int, pair<int, int>>> s2;
for (int i = 0; i < n; i++)
s2.insert({ B[i], { T[i], G[i]} });
ans += fac[n - (int)s2.size() + 1] / 2;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
11 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
11 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |