-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathSubsetsviaBitMask.cpp
More file actions
67 lines (61 loc) · 1.36 KB
/
SubsetsviaBitMask.cpp
File metadata and controls
67 lines (61 loc) · 1.36 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
//#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define pqi priority_queue<int>
#define pqs priority_queue<int,vi,greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<set_precision(y)<<x
void solve(int arr[], int brr[],int size,int x){
int l=0;
int r=size-1;
int resl=0;
int resr=0;
int diff=INT_MAX;
while(l<size && r>=0 ){
if((arr[l]+brr[r]-x)<diff){
resl=l;
resr=r;
diff=abs(arr[l]+brr[r]-x);
}
if(arr[l]+brr[r]>x)r--;
else l++;
}
cout<<"THE arrays are"<<arr[resl]<<" "<<resl<<" "<<brr[resr]<<" "<<resr<<endl;
}
void generate(int n , char a[]){
int j=0;
while(n>0){
int last_bit=(n&1);
if(last_bit==1){
cout<<a[j];
}
j++;
n=n>>1;
}
cout<<endl;
}
void printSubsets(char a[]){
int n=strlen(a);
for(int i=0;i<(1<<n);i++){
generate(i,a);
}
return;
}
signed main(){
char a[100];
cin>>a;
printSubsets(a);
return 0;
}