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>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n; cin >> n;
int a[n], k[n];
for (int& i : a) cin >> i;
for (int& i : k) cin >> i;
pair<int,vector<int>> ans = {0, {}};
for (int mask = 0; mask < 1 << n; mask++) {
vector<int> S;
for (int i = 0; i < n; i++) if (mask & (1 << i)) {
S.push_back(i);
}
int l = S.size();
bool isB = true;
for (int j = 1; j < l; j++) {
if (__builtin_popcount(a[S[j]] & a[S[j-1]]) != k[S[j]]) isB = false;
}
if (isB) {
ans = max(ans, {l, S});
}
}
cout << ans.first << "\n";
for (auto i : ans.second) cout << 1+i << " ";
}
# | 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... |