// #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 += (1<<(x-1));
// cout << x << ' ';
}
A[i] = u;
// cout << A[i] << endl;
}
int ans = 1e18;
int h = 1e18;
for (int j=0 ; j<(1<<m) ; j++){
int k = 0 , cn = 0;
for (int i=0 ; i<m ; i++){
if ((1<<i) & j){
k ^= A[i];
// cout << A[i] << ' ';
cn++;
}
}
if (k == (1<<n) - 1){
// cout << j << ' ' << cn << ' ' << k << endl;
if (cn < h){
ans = j;
h = cn;
continue;
}
if (ans > j && cn == h){
ans = j;
h = cn;
}
}
}
cout << h << endl;
for (int i=0 ; i<m ; i++){
if ((1<<i) & ans){
cout << i+1 << ' ';
}
}
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... |