제출 #1134124

#제출 시각아이디문제언어결과실행 시간메모리
1134124bpptidpNorela (info1cup18_norela)C++20
75 / 100
1047 ms440 KiB
#include<bits/stdc++.h> using namespace std; using ll=long long; ll c[26]; bool bolje(const bitset<25>a,const bitset<25>b){ int c1=a.count(); int c2=b.count(); if(c1>c2)return 0; if(c1<c2)return 1; for(int i=0;i<a.size();++i){ if(a[i]>b[i])return 1; if(a[i]<b[i])return 0; } return 0; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,m; cin>>n>>m; for(int i=0,q,x;i<m;++i){ cin>>q; while(q--){ cin>>x; c[i]|=(1ll<<(x-1)); } } ll g=0; for(int i=0;i<n;++i)g|=(1ll<<i); bitset<25>ans,nw; for(int j=0;j<m;++j) ans[j]=1; for(int msk=1;msk<(1<<m);++msk){ ll x=g; for(int j=0;j<m;++j) if(msk&(1<<j))x^=c[j]; if(x)continue; nw=0; for(int j=0;j<m;++j) nw[j]=((msk&(1<<j))!=0); if(bolje(nw,ans))ans=nw; } cout<<ans.count()<<'\n'; for(int i=0;i<m;++i) if(ans[i])cout<<i+1<<' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...