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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| #include <bits/stdc++.h>
using namespace std; #define INF 0x3f3f3f3f #define LC(x) (x<<1) #define RC(x) ((x<<1)+1) #define MID(x,y) ((x+y)>>1) #define pb(x) emplace_back(x) #define sf(x) scanf("%d", &x) #define sfl(x) scanf("%lld", &x) #define all(a) (a).begin(),(a).end() #define clr(arr,val) memset(arr,val,sizeof(arr)) #define FAST_IO ios::sync_with_stdio(false);cin.tie(0); #define fl(i,f_start,f_end) for(int i=f_start;i<f_end;++i) #define fe(i,f_start,f_end) for(int i=f_start;i<=f_end;++i) #define caseT int _T;scanf("%d",&_T);for (int q=1; q<=_T; ++q) typedef pair<int, int> pii;
typedef long long ll; const double PI = acos(-1.0); const int N = 110; struct BitMap { int bit[N]; void init() { clr(bit, 0); } void insert(int x) { bit[x >> 5] |= (1 << (x & 31)); } int query(int x) { return bit[x >> 5] & (1 << (x & 31)); } vector<int> getall() { vector<int>ret; fl(i, 0, N) { fl(j, 0, 32) { if (bit[i] & (1 << j)) { ret.pb((i << 5) + j); } } } return ret; } } bitmap;
void show(vector<int> v) { fl(i, 0, v.size()) { printf("%d%c", v[i], " \n"[i == (int)v.size() - 1]); } puts(""); }
int main(void) { int testnum = 10; vector<int>test; srand(time(NULL)); fl(i,0,testnum) test.pb(rand() % N); sort(all(test));
show(test); fl(i, 0, testnum) bitmap.insert(test[i]); show(bitmap.getall());
return 0; }
|