// #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 = 3e5 + 5, M = 1e9 + 7, LG = 20;
int n , A[N] , x , sz , m;
void solve(){
cin >> n >> m;
for (int i=0 ; i<m ; i++){
cin >> sz;
int u = 0;
for (int j=0 ; j<sz ; j++){
cin >> x;
u |= (1ll<<(x-1));
}
A[m-i-1] = u;
}
int h = 1e18 , ans = 1e18;
for (int j=0 ; j<(1ll<<m) ; j++){
int k = 0 , cn = 0;
for (int i=0 ; i<m ; i++){
if ((1ll<<i) & j){
k ^= A[i];
cn++;
}
}
if (k == (1ll<<n) - 1){
// cout << j << endl;
if (h > cn){
h = cn;
ans = j;
continue;
}
if (j > ans && h == cn){
ans = j;
}
}
}
cout << h << endl;
vector<int> ans1;
for (int i=0 ; i<m ; i++){
if ((1ll<<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... |