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;
typedef long long ll;
typedef long double ld;
int n,m;
ll mask[30];
int st[30],vf=0;
int best=100;
int sir[30];
void go(int p,ll cur)
{
if(p>m)
{
if(cur==0 && vf<best)
{
best=vf;
for(int i=1;i<=vf;i++)
{
sir[i]=st[i];
}
}
}
else
{
st[++vf]=p;
go(p+1,(cur^mask[p]));
vf--;
go(p+1,cur);
}
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int l;
cin>>l;
for(int j=1;j<=l;j++)
{
int bit;
cin>>bit;
bit--;
mask[i]+=(1LL<<bit);
}
}
go(1,(1LL<<n)-1);
cout<<best<<"\n";
for(int i=1;i<=best;i++)
{
cout<<sir[i]<<" ";
}
cout<<"\n";
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... |