// #include <bits/stdc++.h>
#include <iostream>
// #include <cmath>
// #include <algorithm>
// #include <map>
// #include <unordered_map>
#include <vector>
// #include <iomanip>
// #include <string>
// #include <queue>
// #include <set>
// #include <deque>
using namespace std;
#define endl "\n"
#define pb push_back
// #define int long long
// #define fi first
// #define se second
const int N = 25, M = 1e9 + 7, LG = 20;
int n , x , sz , m;
long long A[N];
void solve(){
cin >> n >> m;
for (int i=0 ; i<m ; i++){
cin >> sz;
for (int j=0 ; j<sz ; j++){
cin >> x;
A[m-i-1] |= (1ll<<(x-1));
}
}
int h = 1e9 , ans = 1e9;
for (int j=(1<<m)-1 ; j>=0 ; j--){
long long k = 0 , cn = 0;
for (int i=0 ; i<m ; i++){
if ((1<<i) & j){
k ^= A[i];
cn++;
}
}
if (k == (1ll<<n) - 1){
// cout << j << endl;
if (h > cn){
h = cn;
ans = j;
continue;
}
}
}
cout << h << endl;
vector<int> ans1;
for (int i=0 ; i<m ; i++){
if ((1<<i) & ans){
ans1.pb(m-i);
}
}
for (int i = ans1.size()-1; i>=0 ; i--){
cout << ans1[i] << ' ';
}
cout << endl;
}
signed main(){
// freopen("" , "r" , stdin);
// freopen("" , "w" , stdout);
// cout << setprecision(30);
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int ts = 1;
// cin >> ts;
while(ts--){
solve();
}
}
| # | 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... |