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;
const int N = 16;
int a[N], k[N];
int bitCount(int x) {
int v = 0;
while (x > 0) {
v += (x & 1);
x >>= 1;
}
return v;
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
cin >> k[i];
}
vector <int> ans = {};
for (int i = 0; i < (1 << n); i++) {
vector <int> v;
for (int j = 0; j < n; j++) {
if ((i & (1 << j)) != 0) {
v.push_back(j);
}
}
bool ch = true;
for (int j = 1; j < (int)v.size(); j++) {
if (k[v[j]] != bitCount((a[v[j - 1]] & a[v[j]]))) ch = false;
}
if (ch) {
if ((int)v.size() > (int)ans.size()) {
ans = v;
}
}
}
cout << (int)ans.size() << "\n";
for (auto it : ans) {
cout << it + 1 << " ";
}
}
# | 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... |