#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
7 ms |
348 KB |
Output is correct |
8 |
Correct |
14 ms |
360 KB |
Output is correct |
9 |
Correct |
16 ms |
348 KB |
Output is correct |
10 |
Correct |
17 ms |
348 KB |
Output is correct |
11 |
Correct |
14 ms |
432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
7 ms |
348 KB |
Output is correct |
8 |
Correct |
14 ms |
360 KB |
Output is correct |
9 |
Correct |
16 ms |
348 KB |
Output is correct |
10 |
Correct |
17 ms |
348 KB |
Output is correct |
11 |
Correct |
14 ms |
432 KB |
Output is correct |
12 |
Correct |
13 ms |
344 KB |
Output is correct |
13 |
Correct |
27 ms |
348 KB |
Output is correct |
14 |
Correct |
27 ms |
348 KB |
Output is correct |
15 |
Correct |
27 ms |
344 KB |
Output is correct |
16 |
Correct |
27 ms |
348 KB |
Output is correct |
17 |
Correct |
27 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
7 ms |
348 KB |
Output is correct |
8 |
Correct |
14 ms |
360 KB |
Output is correct |
9 |
Correct |
16 ms |
348 KB |
Output is correct |
10 |
Correct |
17 ms |
348 KB |
Output is correct |
11 |
Correct |
14 ms |
432 KB |
Output is correct |
12 |
Correct |
13 ms |
344 KB |
Output is correct |
13 |
Correct |
27 ms |
348 KB |
Output is correct |
14 |
Correct |
27 ms |
348 KB |
Output is correct |
15 |
Correct |
27 ms |
344 KB |
Output is correct |
16 |
Correct |
27 ms |
348 KB |
Output is correct |
17 |
Correct |
27 ms |
348 KB |
Output is correct |
18 |
Correct |
53 ms |
348 KB |
Output is correct |
19 |
Correct |
52 ms |
348 KB |
Output is correct |
20 |
Correct |
133 ms |
348 KB |
Output is correct |
21 |
Correct |
105 ms |
416 KB |
Output is correct |
22 |
Correct |
105 ms |
348 KB |
Output is correct |
23 |
Correct |
125 ms |
408 KB |
Output is correct |