#include "museum.h"
#include <algorithm>
long long b[105] = { 0 }, t[105] = { 0 }, g[105] = { 0 };
long long bb[101 * 101] = { 0 }, tt[101 * 101] = { 0 }, gg[101 * 101] = { 0 };
long long tot[101 * 101 * 101] = { 0 };
#define AB B[i] * 101 + T[i]
#define BC T[i] * 101 + G[i]
#define AC B[i] * 101 + G[i]
#define ABC B[i] * 101 * 101 + T[i] * 101 + G[i]
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
for (int i = 0; i < 101 * 101 * 101; i++) tot[i] = 0;
for (int i = 0; i < 101 * 101; i++) bb[i] = tt[i] = gg[i] = 0;
for (int i = 0; i < 105; i++) b[i] = t[i] = g[i] = 0;
long long n = B.size();
long long ans = 0;
for (int i = 0; i < n; i++) {
ans += b[B[i]] + t[T[i]] + g[G[i]] - bb[AB] - tt[BC] - gg[AC] + tot[ABC];
b[B[i]]++;
t[T[i]]++;
g[G[i]]++;
bb[AB]++;
tt[BC]++;
gg[AC]++;
tot[ABC]++;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
8704 KB |
Output is correct |
2 |
Correct |
11 ms |
8704 KB |
Output is correct |
3 |
Correct |
9 ms |
8704 KB |
Output is correct |
4 |
Correct |
11 ms |
8704 KB |
Output is correct |
5 |
Correct |
10 ms |
8704 KB |
Output is correct |
6 |
Correct |
11 ms |
8704 KB |
Output is correct |
7 |
Correct |
9 ms |
8704 KB |
Output is correct |
8 |
Correct |
10 ms |
8704 KB |
Output is correct |
9 |
Correct |
12 ms |
8704 KB |
Output is correct |
10 |
Correct |
12 ms |
8704 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
8704 KB |
Output is correct |
2 |
Correct |
11 ms |
8704 KB |
Output is correct |
3 |
Correct |
9 ms |
8704 KB |
Output is correct |
4 |
Correct |
11 ms |
8704 KB |
Output is correct |
5 |
Correct |
10 ms |
8704 KB |
Output is correct |
6 |
Correct |
11 ms |
8704 KB |
Output is correct |
7 |
Correct |
9 ms |
8704 KB |
Output is correct |
8 |
Correct |
10 ms |
8704 KB |
Output is correct |
9 |
Correct |
12 ms |
8704 KB |
Output is correct |
10 |
Correct |
12 ms |
8704 KB |
Output is correct |
11 |
Correct |
13 ms |
8832 KB |
Output is correct |
12 |
Correct |
20 ms |
9392 KB |
Output is correct |
13 |
Correct |
32 ms |
10100 KB |
Output is correct |
14 |
Correct |
42 ms |
10736 KB |
Output is correct |
15 |
Correct |
57 ms |
11756 KB |
Output is correct |
16 |
Correct |
82 ms |
13544 KB |
Output is correct |
17 |
Correct |
82 ms |
13548 KB |
Output is correct |
18 |
Correct |
84 ms |
13540 KB |
Output is correct |
19 |
Correct |
95 ms |
13544 KB |
Output is correct |
20 |
Correct |
97 ms |
13544 KB |
Output is correct |