#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++) {
aa[--a[i]].push_back(i);
bb[--b[i]].push_back(i);
cc[--c[i]].push_back(i);
}
ll ans = 0;
for (int i = 0; i < 100; i++) {
int c1 = 0;
vector<int> tm[100], tb[100];
// ��ġ�� �ֵ� �߿�...
// ���ο� b�迭�� �ٽ� �Ѹ���??
for (int t : aa[i]) {
ch[t]++;
c1++;
tm[b[t]].push_back(t);
tb[c[t]].push_back(t);
}
ans += (c1) * (c1 - 1LL) / 2;
for (int j = 0; j < 100; j++) {
vector<int> ttm[100];
int c2 = 0;
for (int t : tm[j]) {
if (ch[t]) {
ca[t]++;
c2++;
ttm[c[t]].push_back(t);
}
}
ans -= (c2) * (c2 - 1LL) / 2;
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : ttm[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 : tm[j]) {
if (ch[t])
ca[t]--;
}
}
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : tb[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++) {
vector<int> tm[100];
int c2 = 0;
for (int t : bb[j]) {
ca[t]++;
c2++;
tm[c[t]].push_back(t);
}
ans += (c2) * (c2 - 1LL) / 2;
for (int k = 0; k < 100; k++) {
int c3 = 0;
for (int t : tm[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:107:12: warning: unused variable 't' [-Wunused-variable]
for (int t : cc[k]) {
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
384 KB |
Output is correct |
2 |
Correct |
10 ms |
384 KB |
Output is correct |
3 |
Correct |
10 ms |
384 KB |
Output is correct |
4 |
Correct |
9 ms |
384 KB |
Output is correct |
5 |
Correct |
10 ms |
256 KB |
Output is correct |
6 |
Correct |
10 ms |
256 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
8 |
Correct |
10 ms |
384 KB |
Output is correct |
9 |
Correct |
11 ms |
384 KB |
Output is correct |
10 |
Correct |
10 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
384 KB |
Output is correct |
2 |
Correct |
10 ms |
384 KB |
Output is correct |
3 |
Correct |
10 ms |
384 KB |
Output is correct |
4 |
Correct |
9 ms |
384 KB |
Output is correct |
5 |
Correct |
10 ms |
256 KB |
Output is correct |
6 |
Correct |
10 ms |
256 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
8 |
Correct |
10 ms |
384 KB |
Output is correct |
9 |
Correct |
11 ms |
384 KB |
Output is correct |
10 |
Correct |
10 ms |
512 KB |
Output is correct |
11 |
Correct |
14 ms |
640 KB |
Output is correct |
12 |
Correct |
24 ms |
1792 KB |
Output is correct |
13 |
Correct |
49 ms |
3060 KB |
Output is correct |
14 |
Correct |
63 ms |
3832 KB |
Output is correct |
15 |
Correct |
91 ms |
6132 KB |
Output is correct |
16 |
Correct |
101 ms |
10948 KB |
Output is correct |
17 |
Correct |
101 ms |
8936 KB |
Output is correct |
18 |
Correct |
126 ms |
8256 KB |
Output is correct |
19 |
Correct |
147 ms |
8428 KB |
Output is correct |
20 |
Correct |
136 ms |
8548 KB |
Output is correct |