This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
int n;
int a[16],b[16];
int main(){
cin>>n;
for(int k=0;k<n;k++){
cin>>a[k];
}
for(int k=0;k<n;k++){
cin>>b[k];
}
bitset<32> btans;
int ans=0;
for(int k=1;k<(1<<n);k++){
bitset<32> bt=k;
int cnt=0;
int wina=0;
int ind=0;
for(int i=0;i<n;i++){
if(bt[i]==1){
cnt++;
if(cnt==1){
wina=i;
}
if(cnt>1){
int f=a[i]&a[wina];
int r=__builtin_popcount(f);
if(r!=b[i]){
ind=1;
break;
}
wina=i;
}
}
}
if(ind==0&&cnt>ans){
ans=cnt;
btans=bt;
}
}
cout<<ans<<"\n";
for(int k=0;k<n;k++){
if(btans[k]==1)
cout<<k+1<<' ';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |