#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> buyu(m, 0);
for(int i = 0; i < m; i++) {
int k;
cin >> k;
for(int j = 0; j < k; j++) {
int x;
cin >> x;
x--;
buyu[i] |= 1 << x;
}
}
int hedef = (1 << n) - 1;
int en_az = m + 1;
vector<int> cozum;
for(int mask = 0; mask < (1 << m); mask++) {
int s = 0;
vector<int> t;
for(int i = 0; i < m; i++) {
if(mask & (1 << i)) {
s ^= buyu[i];
t.push_back(i + 1);
}
}
if(s == hedef && (t.size() < en_az || (t.size() == en_az && t < cozum))) {
en_az = t.size();
cozum = t;
}
}
cout << en_az << "\n";
for(int i = 0; i < cozum.size(); i++) {
if(i) cout << " ";
cout << cozum[i];
}
cout << "\n";
}
| # | 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... |