// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <set>
#include <deque>
#include <numeric>
#include <stack>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
void fast_io() {
// freopen("", "r", stdin);
// freopen("", "w", stdout);
ios::sync_with_stdio(0);
cin.tie();
cout.tie();
cout << setprecision(9);
}
#define int long long
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
void solve() {
int n, m; cin >> n >> m;
int a[m] = {};
for (int i = 0; i < m; i++){
int s; cin >> s;
while (s--){
int x; cin >> x;
x--;
a[i] += (1ll << x);
}
}
int ans = (1ll << (m + 1)) - 1, y = 80;
for (int P = m - 1; P >= 0; P--){
int i = (1ll << (P));
int K = (1ll << (P + 1));
while (i < K){
int cur = 0;
for (int j = m - 1; j >= 0; j--){
if (((i >> j) & 1)){
cur ^= a[(m - 1) - (j)];
}
}
if (cur == ((1ll << n) - 1)){
int x = __builtin_popcount(i);
if (x < y) {ans = i; y = x;}
else if (x == y) ans = max(ans, i);
}
i++;
}
}
cout << y << endl;
for (int j = m - 1; j >= 0; j--){
if (((ans >> j) & 1)){
cout << (m - 1) - (j) + 1 << ' ';
}
}
cout << endl;
}
signed main() {
fast_io();
srand(chrono::steady_clock::now().time_since_epoch().count());
int tc = 1;
// cin >> tc;
while (tc--) solve();
return 0;
}
| # | 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... |