// #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 int long long
#define endl "\n"
#define fi first
#define se second
const int M=1e9+7;
const int inf = 1e15;
const int LOG=17;
const int N=2e5+5;
int n , m , c , w , k , t=1 , q=1 , x , y , z , l , r;
void solve(){
cin >> n >> m;
vector<vector<int>>a(m);
for (int i=0;i<m;i++){
cin >> k;
vector<int>b(k);
for (int j=0;j<k;j++){
cin >> b[j];
}
a[i]=b;
}
for (int i=1;i<(1<<m);i++){
vector<int>vi(n+1);
for (int j=0;j<m;j++){
if (i&(1<<j)){
for (int k:a[j]){
vi[k]^=1;
}
}
}
bool f=1;
for (int j=1;j<=n;j++){
if (!vi[j])f=0;
}
if (f){
cout << __builtin_popcount(i) << endl;
for (int j=0;j<m;j++){
if (i&(1<<j)){
cout << j+1 << " ";
}
}
cout << endl;
return;
}
}
}
signed main()
{
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r" ,stdin);
// freopen("output.txt","w",stdout);
// #endif
ios::sync_with_stdio(0);//DO NOT USE IN INTERACTIVE
cin.tie(0), cout.tie(0);//DO NOT USE IN INTERACTIVE
cout << fixed << setprecision(9);
srand(time(0));
// int t=1;
// cin >> t;
for (int _=1;_<=t;_++){
solve();
q++;
}
}
| # | 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... |