#include "museum.h"
#include <map>
#include <utility>
#include <tuple>
using namespace std;
using ll = long long;
long long CountSimilarPairs(vector<int> b, vector<int> t, vector<int> g) {
const int n = b.size();
ll res = 0;
vector v({b, t, g});
for (int i = 0; i < 3; i++) {
map<int, int> cnt;
for (int e : v[i]) {
res += cnt[e];
cnt[e]++;
}
}
for (int i = 0; i < 3; i++) {
for (int j = i + 1; j < 3; j++) {
map<pair<int, int>, int> cnt;
for (int k = 0; k < n; k++) {
const pair p(v[i][k], v[j][k]);
res -= cnt[p];
cnt[p]++;
}
}
}
map<tuple<int, int, int>, int> cnt;
for (int i = 0; i < n; i++) {
const tuple T(b[i], t[i], g[i]);
res += cnt[T];
cnt[T]++;
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
384 KB |
Output is correct |
8 |
Correct |
7 ms |
512 KB |
Output is correct |
9 |
Correct |
10 ms |
512 KB |
Output is correct |
10 |
Correct |
10 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
384 KB |
Output is correct |
8 |
Correct |
7 ms |
512 KB |
Output is correct |
9 |
Correct |
10 ms |
512 KB |
Output is correct |
10 |
Correct |
10 ms |
512 KB |
Output is correct |
11 |
Correct |
17 ms |
896 KB |
Output is correct |
12 |
Correct |
22 ms |
1664 KB |
Output is correct |
13 |
Correct |
118 ms |
5592 KB |
Output is correct |
14 |
Correct |
183 ms |
8116 KB |
Output is correct |
15 |
Correct |
288 ms |
11964 KB |
Output is correct |
16 |
Correct |
84 ms |
9836 KB |
Output is correct |
17 |
Correct |
180 ms |
9944 KB |
Output is correct |
18 |
Correct |
373 ms |
13744 KB |
Output is correct |
19 |
Correct |
477 ms |
18616 KB |
Output is correct |
20 |
Correct |
510 ms |
18744 KB |
Output is correct |