Submission #524611

#TimeUsernameProblemLanguageResultExecution timeMemory
524611lucriNorela (info1cup18_norela)C++17
0 / 100
1 ms204 KiB
#include <fstream> using namespace std; ifstream in("norela.in"); ofstream out("norela.out"); long long p[65],n,m,nrmin=100,cmin[30],q,x,nr[30]; bool ver[30]; void bck(long long poz,long long ceva,long long folosit) { if(poz==0) { if(ceva!=p[n]-1) return; if(folosit<nrmin) { nrmin=0; for(long long i=1;i<=m;++i) { if(ver[i]==true) cmin[++nrmin]=i; } } else if(folosit == nrmin) { int p = 1; for(long long i = 1; i <= m; i++) { if(cmin[p] == i && ver[i] == false) { return ; } if(cmin[p] > i && ver[i] == true) { nrmin=0; for(long long i=1;i<=m;++i) { if(ver[i]==true) cmin[++nrmin]=i; } return ; } if(cmin[p] == i && ver[i] == true) { p++; } } } return; } bck(poz-1,ceva,folosit); ceva^=nr[poz]; ver[poz]=true; bck(poz-1,ceva,folosit+1); ceva^=nr[poz]; ver[poz]=false; return; } int main() { p[0]=1; for(long long i=1;i<=60;++i) p[i]=p[i-1]*2; in>>n>>m; for(long long i=1;i<=m;++i) { in>>q; for(long long j=1;j<=q;++j) { in>>x; nr[i]+=p[x-1]; } } bck(m,0,0); out<<nrmin<<'\n'; for(long long i=1;i<=nrmin;++i) out<<cmin[i]<<' '; 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...