#include "museum.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cnt1[101], cnt2[101][101], cnt3[101][101][101];
long long CountSimilarPairs(vector<int> B, vector<int> T, vector<int> G) {
int n = B.size();
ll ans = 0;
for(int i = 0; i < n; i++) {
ans += cnt1[B[i]];
cnt1[B[i]]++;
}
for(int i = 0; i < 101; i++) cnt1[i] = 0;
for(int i = 0; i < n; i++) {
ans += cnt1[T[i]];
cnt1[T[i]]++;
}
for(int i = 0; i < 101; i++) cnt1[i] = 0;
for(int i = 0; i < n; i++) {
ans += cnt1[G[i]];
cnt1[G[i]]++;
}
for(int i = 0; i < n; i++) {
ans -= cnt2[B[i]][T[i]];
cnt2[B[i]][T[i]]++;
}
for(int i = 0; i < 101; i++) for(int j = 0; j < 101; j++) cnt2[i][j] = 0;
for(int i = 0; i < n; i++) {
ans -= cnt2[T[i]][G[i]];
cnt2[T[i]][G[i]]++;
}
for(int i = 0; i < 101; i++) for(int j = 0; j < 101; j++) cnt2[i][j] = 0;
for(int i = 0; i < n; i++) {
ans -= cnt2[B[i]][G[i]];
cnt2[B[i]][G[i]]++;
}
for(int i = 0; i < n; i++) {
ans += cnt3[B[i]][T[i]][G[i]];
cnt3[B[i]][T[i]][G[i]]++;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
776 KB |
Output is correct |
5 |
Correct |
7 ms |
1920 KB |
Output is correct |
6 |
Correct |
8 ms |
2816 KB |
Output is correct |
7 |
Correct |
8 ms |
3584 KB |
Output is correct |
8 |
Correct |
6 ms |
640 KB |
Output is correct |
9 |
Correct |
12 ms |
5632 KB |
Output is correct |
10 |
Correct |
11 ms |
5632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
776 KB |
Output is correct |
5 |
Correct |
7 ms |
1920 KB |
Output is correct |
6 |
Correct |
8 ms |
2816 KB |
Output is correct |
7 |
Correct |
8 ms |
3584 KB |
Output is correct |
8 |
Correct |
6 ms |
640 KB |
Output is correct |
9 |
Correct |
12 ms |
5632 KB |
Output is correct |
10 |
Correct |
11 ms |
5632 KB |
Output is correct |
11 |
Correct |
12 ms |
8192 KB |
Output is correct |
12 |
Correct |
19 ms |
1280 KB |
Output is correct |
13 |
Correct |
34 ms |
8564 KB |
Output is correct |
14 |
Correct |
52 ms |
10476 KB |
Output is correct |
15 |
Correct |
62 ms |
11460 KB |
Output is correct |
16 |
Correct |
75 ms |
5348 KB |
Output is correct |
17 |
Correct |
86 ms |
5480 KB |
Output is correct |
18 |
Correct |
93 ms |
7528 KB |
Output is correct |
19 |
Correct |
103 ms |
13288 KB |
Output is correct |
20 |
Correct |
104 ms |
13292 KB |
Output is correct |