Submission #524611

# Submission time Handle Problem Language Result Execution time Memory
524611 2022-02-09T16:01:15 Z lucri Norela (info1cup18_norela) C++17
0 / 100
1 ms 204 KB
#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 time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -