#include <bits/stdc++.h>
using namespace std;
int sol,nrsol=2100000000,n,m;
long long vr[30];
void bkt(long long nrc, int poz, int ans, int cnt)
{
if(poz==m)
{
if(nrc==(1<<n)-1)
{
if(nrsol>cnt)
{
nrsol=cnt;
sol=ans;
}
}
return ;
}
bkt(nrc^vr[poz],poz+1,ans^(1<<poz),cnt+1);
bkt(nrc,poz+1,ans,cnt);
}
int main()
{
cin.sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for(int i=0; i<m; i++)
{
int q;
cin>>q;
for(int j=0; j<q; j++)
{
int x;
cin>>x;
x--;
vr[i]^=(1<<(x));
}
}
bkt(0,0,0,0);
cout<<nrsol<<'\n';
for(int i=0; i<=m-1; i++)
if(sol&(1<<i))
cout<<i+1<<" ";
cout<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
212 KB |
Output is correct |
2 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
212 KB |
Output is correct |
2 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
212 KB |
Output is correct |
2 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
212 KB |
Output is correct |
2 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |