제출 #1134096

#제출 시각아이디문제언어결과실행 시간메모리
1134096bpptidpNorela (info1cup18_norela)C++20
75 / 100
1094 ms6728 KiB
#include<bits/stdc++.h> using namespace std; int n,m; vector<int>ans; vector<int>sp[27],koji[66]; bitset<66>bsp[26]; bool losi[(1<<25)],imao[(1<<25)]; bool bolje(const string&a,const string&b){ int c1=count(a.begin(),a.end(),'1'); int c2=count(b.begin(),b.end(),'1'); 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); cin>>n>>m; for(int i=0,q,x;i<m;++i){ cin>>q; while(q--){ cin>>x; sp[i].push_back(x); koji[x].push_back(i); bsp[i][x]=1; } } for(int x=1;x<=n;++x){ int msk=0; for(int i:koji[x]) msk^=(1<<i); if(imao[msk])continue; imao[msk]=1; for(int s=msk;s;s=(s-1)&msk) if(__builtin_popcount(s)&1^1)losi[s]=1; } string ans; for(int i=0;i<m;++i) ans.push_back('1'); for(int msk=1;msk<=(1<<m);++msk){ if(losi[msk])continue; bitset<66>b; for(int i=0;i<m;++i) if(msk&(1<<i))b^=bsp[i]; if(b.count()!=n)continue; string s; for(int j=0;j<m;++j) s.push_back('0'+((msk&(1<<j))!=0)); if(bolje(s,ans))ans=s; } cout<<count(ans.begin(),ans.end(),'1')<<'\n'; for(int i=0;i<m;++i) if(ans[i]=='1')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...