Submission #97909

#TimeUsernameProblemLanguageResultExecution timeMemory
97909314rateNorela (info1cup18_norela)C++14
100 / 100
91 ms512 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...