-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBit Problem.cpp
More file actions
executable file
·50 lines (45 loc) · 1.03 KB
/
Copy pathBit Problem.cpp
File metadata and controls
executable file
·50 lines (45 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int dpa[(1 << 20) + 1][21];
int dpb[(1 << 20) + 1][21];
int cnt[(1 << 20) + 1];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<int> v(n);
for (auto& x : v) {
cin >> x;
cnt[x]++;
}
for (int j = 0; j < 20; j++) {
for (int i = 0; i < (1 << 20); i++) {
if (j == 0) {
dpa[i][j] += cnt[i];
if (i & (1 << j)) dpa[i][j] += cnt[i ^ (1 << j)];
} else {
dpa[i][j] += dpa[i][j - 1];
if (i & (1 << j)) dpa[i][j] += dpa[i ^ (1 << j)][j - 1];
}
}
}
for (int j = 0; j < 20; j++) {
for (int i = 0; i < (1 << 20); i++) {
if (j == 0) {
dpb[i][j] += cnt[i];
if ((i & (1 << j)) == 0) dpb[i][j] += cnt[i ^ (1 << j)];
} else {
dpb[i][j] += dpb[i][j - 1];
if ((i & (1 << j)) == 0) dpb[i][j] += dpb[i ^ (1 << j)][j - 1];
}
}
}
for (int i = 0; i < n; i++) {
int x = (~v[i]) & 0xFFFFF;
cout << dpa[v[i]][19] << " " << dpb[v[i]][19] << " " << n - dpa[x][19] << "\n";
}
return 0;
}