#include <bits/stdc++.h>
#define int long long
const int MAXM = 24;
const int MAXN = 60;
using namespace std;
long long v[MAXM];
signed main()
{
int n, m, q, bit, i, mn;
long long rez, mask, cmask;
cin >> n >> m;
for( i = 0; i < m; i++ ){
cin >> q;
while(q--){
cin >> bit;
bit--;
v[i] |= (1 << bit);
}
}
mn = m + 1;
cmask = 0;
for( mask = 0; mask < (1 << m); mask++ ){
rez = 0;
for( i = 0; i < m; i++ ){
if(mask & (1 << i)){
rez ^= v[i];
}
}
if(__builtin_popcount(rez) == n && __builtin_popcount(mask) < mn){
mn = __builtin_popcount(mask);
cmask = mask;
}
}
cout << mn << "\n";
for( i = 0; i < m; i++ ){
if(cmask & (1 << i))
cout << i + 1 << " ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Output is correct |
2 |
Incorrect |
16 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Output is correct |
2 |
Incorrect |
16 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Output is correct |
2 |
Incorrect |
16 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Output is correct |
2 |
Incorrect |
16 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |