#include <bits/stdc++.h>
using namespace std;
int sol,nrsol=INT_MAX,n,m;
long long vr[30];
void bec(long long mcarti, int act, int mvraji, int nrvraja)
{
if(act==m)
{
if(mcarti==(1LL<<n)-1)
{
if(nrsol>nrvraja)
{
nrsol=nrvraja;
sol=mvraji;
}
}
return ;
}
bec(mcarti^vr[act],act+1,mvraji^(1<<act),nrvraja+1);
bec(mcarti,act+1,mvraji,nrvraja);
}
int main()
{
//freopen("norela.in","r",stdin);
//freopen("norela.out","w",stdout);
cin.sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for(int i=0; i<m; ++i)
{
int q;
cin>>q;
for(int j=0; j<q; ++j)
{
int x;
cin>>x;
x--;
vr[i]^=(1LL<<(x));
}
}
bec(0,0,0,0);
cout<<nrsol<<'\n';
for(int i=0; i<=m-1; ++i)if(sol&(1<<i))cout<<i+1<<" ";
cout<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
384 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
8 |
Correct |
15 ms |
384 KB |
Output is correct |
9 |
Correct |
16 ms |
384 KB |
Output is correct |
10 |
Correct |
15 ms |
512 KB |
Output is correct |
11 |
Correct |
15 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
384 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
8 |
Correct |
15 ms |
384 KB |
Output is correct |
9 |
Correct |
16 ms |
384 KB |
Output is correct |
10 |
Correct |
15 ms |
512 KB |
Output is correct |
11 |
Correct |
15 ms |
384 KB |
Output is correct |
12 |
Correct |
15 ms |
384 KB |
Output is correct |
13 |
Correct |
26 ms |
384 KB |
Output is correct |
14 |
Correct |
26 ms |
384 KB |
Output is correct |
15 |
Correct |
27 ms |
384 KB |
Output is correct |
16 |
Correct |
27 ms |
384 KB |
Output is correct |
17 |
Correct |
28 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
384 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
8 |
Correct |
15 ms |
384 KB |
Output is correct |
9 |
Correct |
16 ms |
384 KB |
Output is correct |
10 |
Correct |
15 ms |
512 KB |
Output is correct |
11 |
Correct |
15 ms |
384 KB |
Output is correct |
12 |
Correct |
15 ms |
384 KB |
Output is correct |
13 |
Correct |
26 ms |
384 KB |
Output is correct |
14 |
Correct |
26 ms |
384 KB |
Output is correct |
15 |
Correct |
27 ms |
384 KB |
Output is correct |
16 |
Correct |
27 ms |
384 KB |
Output is correct |
17 |
Correct |
28 ms |
384 KB |
Output is correct |
18 |
Correct |
49 ms |
384 KB |
Output is correct |
19 |
Correct |
46 ms |
384 KB |
Output is correct |
20 |
Correct |
87 ms |
388 KB |
Output is correct |
21 |
Correct |
90 ms |
504 KB |
Output is correct |
22 |
Correct |
85 ms |
384 KB |
Output is correct |
23 |
Correct |
83 ms |
384 KB |
Output is correct |