// #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[i] = u;
}
int h = 1e18;
vector<int> f(n+10 , 1e18);
for (int j=0 ; j<(1<<m) ; j++){
int k = 0 , cn = 0;
for (int i=0 ; i<m ; i++){
if ((1ll<<i) & j){
k ^= A[i];
cn++;
}
}
if (k == (1<<n) - 1){
vector<int> g;
for (int i=0 ; i<m ; i++){
if ((1ll<<i) & j){
g.pb(i+1);
}
}
if (h > cn){
h = cn;
swap(f,g);
continue;
}
if (h == cn){
for (int i=0 ; i<h ; i++){
if (f[i] == g[i]){
continue;
}else{
if (f[i] > g[i]){
swap(f,g);
}
break;
}
}
}
}
}
cout << f.size() << endl;
for (int i : f) cout << 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... |