-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSOS Bit Problem.cpp
More file actions
52 lines (43 loc) · 1005 Bytes
/
SOS Bit Problem.cpp
File metadata and controls
52 lines (43 loc) · 1005 Bytes
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
51
52
/// Alhamdulillah
#include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define ll long long
#define eb emplace_back
#define vec vector<ll>
#define forr(i, a, b) for (ll i = a; i < b; i++)
const int MAX = (1 << 20);
int main() {
fast;
ll i, j, x, n;
vec v, cnt(MAX, 0);
cin >> n;
forr(i, 0, n) {
cin >> x;
v.eb(x);
cnt[x]++;
}
vec sup = cnt;
vec sub = cnt;
forr(i, 0, 20) {
forr(j, 0, MAX) {
if (j & (1 << i)) {
sub[j] += sub[j ^ (1 << i)];
}
}
}
forr(i, 0, 20) {
forr(j, 0, MAX) {
if (!(j & (1 << i))) {
sup[j] += sup[j | (1 << i)];
}
}
}
for (auto x : v) {
cout << sub[x] << " " << sup[x] << " ";
cout << n - sub[(MAX - 1) ^ x] << endl;
}
}