#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
vector<int> b(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
}
for(int i = 0; i < n; i++) {
cin >> b[i];
}
vector<int> ans;
for(int i = 0; i < (1LL << n); i++) {
vector<int> current;
int pret = - 1;
int ok = 1;
for(int j = 0; j < n; j++) {
if(i & (1LL << j)) {
if(pret != - 1 && __builtin_popcount((a[pret] & a[j])) != b[j]) {
ok = 0;
break;
}
pret = j;
current.push_back(j + 1);
}
}
if(ok && ans.size() < current.size()) {
ans = current;
}
}
cout << ans.size();
cout << endl;
for(auto it : ans) {
cout << it << " ";
}
}
# | 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... |