Submission #1134214

#TimeUsernameProblemLanguageResultExecution timeMemory
1134214bpptidpNorela (info1cup18_norela)C++20
75 / 100
1036 ms436 KiB
#include<bits/stdc++.h> using namespace std; using ll=long long; ll c[26]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,m; cin>>n>>m; int cn=0; for(int i=0,q,x;i<m;++i){ cin>>q; cn+=(q==n); while(q--){ cin>>x; c[i]|=(1ll<<(x-1)); } } if(cn==m){ cout<<"1\n1"; return 0; } ll g=0; for(int i=0;i<n;++i)g|=(1ll<<i); int ans=0,nw,cans=m; for(int j=0;j<m;++j) ans|=(1<<(m-j-1)); for(int msk=1;msk<(1<<m);++msk){ ll x=g,pc2=0; nw=0; for(int j=0;j<m;++j){ if(msk&(1<<j)){ x^=c[j]; nw|=(1<<(m-j-1)); ++pc2; } } if(!x){ int pc1=cans; if(pc1<pc2)continue; if(pc1>pc2){ans=nw;cans=pc2;} else ans=max(ans,nw); } } cout<<cans<<'\n'; for(int i=m-1;~i;--i) if(ans&(1<<i))cout<<m-i<<' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...