#include<iostream>
using namespace std;
using ll=long long;
ll c[26],x,pc2;
int ans,nw,msk,cans;
int n,m;
void r(int i){
if(i>=m){
if(!x){
int pc1=cans;
if(pc1<pc2)return;
if(pc1>pc2){ans=nw;cans=pc2;}
else ans=max(ans,nw);
}
return;
}
r(i+1);
x^=c[i];
msk^=(1<<i);
nw^=(1<<(m-i-1));
++pc2;
r(i+1);
msk^=(1<<i);
nw^=(1<<(m-i-1));
x^=c[i];
--pc2;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
for(int i=0,q,x;i<m;++i){
cin>>q;
while(q--){
cin>>x;
c[i]|=(1ll<<(x-1));
}
}
for(int i=0;i<n;++i)
x|=(1ll<<i);
cans=m;
for(int j=0;j<m;++j)
ans|=(1<<(j));
r(0);
cout<<cans<<'\n';
for(int i=m-1;~i;--i)
if(ans&(1<<i))cout<<m-i<<' ';
}
# | 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... |