This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m,a[30];
int maskmare;
vector<int>sol,cur;
int curnum;
void bkt(int pos)
{
if (pos == m + 1)
{
if (curnum == maskmare and (cur.size() < sol.size() or sol.size() == 0))
sol = cur;
}
else
{
curnum ^= a[pos];
cur.push_back(pos);
bkt(pos + 1);
curnum ^= a[pos];
cur.pop_back();
bkt(pos + 1);
}
}
signed main()
{
cin >> n >> m;
maskmare = (1ll << n) - 1;
for (int i = 1; i <= m; i++)
{
int cate;
cin >> cate;
for (int j = 1; j <= cate; j++)
{
int x;
cin >> x;
a[i] += (1ll << (x - 1));
}
}
bkt(1);
cout << sol.size() << '\n';
for (auto it : sol)
cout << it << ' ';
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... |