#include "museum.h"
using namespace std;
typedef long long ll;
char ch[200000];
char ca[200000];
vector<int> aa[100], bb[100], cc[100];
long long CountSimilarPairs(std::vector<int> a, std::vector<int> b, std::vector<int> c) {
int n = a.size();
for (int i = 0; i < n; i++) {
a[i]--;
aa[a[i]].push_back(i);
b[i]--;
bb[b[i]].push_back(i);
c[i]--;
cc[c[i]].push_back(i);
}
ll ans = 0;
for (int i = 0; i < 100; i++) {
int c1 = 0;
for (int t : aa[i]) {
ch[t]++;
c1++;
}
ans += (c1) * (c1 - 1LL) / 2;
for (int j = 0; j < 100; j++) {
int c2 = 0;
for (int t : bb[j]) {
if (ch[t]) {
ca[t]++;
c2++;
}
}
ans -= (c2) * (c2 - 1LL) / 2;
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : cc[k]) {
if (ca[t])
c3++;
}
ans += (c3) * (c3 - 1LL) / 2;
// if (i == 0 && j == 0 && k== 0) printf("%lld : %d %d %d\n", ans, c1, c2, c3);
}
for (int t : bb[j]) {
if (ch[t])
ca[t]--;
}
}
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : cc[k]) {
if (ch[t])
c3++;
}
ans -= (c3) * (c3 - 1LL) / 2;
}
for (int t : aa[i])
ch[t]--;
}
// 2��°���� ��ġ�� ��.
for (int j = 0; j < 100; j++) {
int c2 = 0;
for (int t : bb[j]) {
ca[t]++;
c2++;
}
ans += (c2) * (c2 - 1LL) / 2;
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : cc[k]) {
if (ca[t])
c3++;
}
ans -= (c3) * (c3 - 1LL) / 2;
// if (i == 0 && j == 0 && k== 0) printf("%lld : %d %d %d\n", ans, c1, c2, c3);
}
for (int t : bb[j]) {
ca[t]--;
}
}
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : cc[k]) {
c3++;
}
ans += (c3) * (c3 - 1LL) / 2;
// if (i == 0 && j == 0 && k== 0) printf("%lld : %d %d %d\n", ans, c1, c2, c3);
}
return ans;
}
Compilation message
museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:102:12: warning: unused variable 't' [-Wunused-variable]
for (int t : cc[k]) {
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
9 ms |
384 KB |
Output is correct |
4 |
Correct |
9 ms |
384 KB |
Output is correct |
5 |
Correct |
17 ms |
384 KB |
Output is correct |
6 |
Correct |
23 ms |
384 KB |
Output is correct |
7 |
Correct |
28 ms |
384 KB |
Output is correct |
8 |
Correct |
32 ms |
512 KB |
Output is correct |
9 |
Correct |
43 ms |
512 KB |
Output is correct |
10 |
Correct |
42 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
9 ms |
384 KB |
Output is correct |
4 |
Correct |
9 ms |
384 KB |
Output is correct |
5 |
Correct |
17 ms |
384 KB |
Output is correct |
6 |
Correct |
23 ms |
384 KB |
Output is correct |
7 |
Correct |
28 ms |
384 KB |
Output is correct |
8 |
Correct |
32 ms |
512 KB |
Output is correct |
9 |
Correct |
43 ms |
512 KB |
Output is correct |
10 |
Correct |
42 ms |
512 KB |
Output is correct |
11 |
Correct |
88 ms |
640 KB |
Output is correct |
12 |
Correct |
338 ms |
1632 KB |
Output is correct |
13 |
Correct |
784 ms |
2932 KB |
Output is correct |
14 |
Execution timed out |
1099 ms |
3824 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |