This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll menor,N,M,mascaras[30],alvo,menormask;
void brute(int atual,ll bitmask,int qtd,ll outramask){
if(atual == M){
if(bitmask != alvo) return;
if(qtd < menor){
menor = qtd;
menormask = outramask;
}
else if(qtd == menor){
for(ll i = 0;i<M;i++){
if((outramask & (1LL << i)) && !(menormask & (1LL << i)) ){
menormask = outramask;
break;
}
}
}
return;
}
brute(atual+1, bitmask,qtd, outramask );
brute(atual+1, bitmask ^ mascaras[atual], qtd+1, outramask | (1LL << atual) );
}
int main(){
cin >> N >> M;
menor = 2*M;
alvo = (1LL << N) - 1;
for(ll i = 0;i<M;i++){
ll x;
cin >> x;
while(x--){
ll y;
cin >> y;
y--;
mascaras[i] |= (1LL << y);
}
}
brute(0,0,0,0);
cout << menor << endl;
for(ll i = 0;i<M;i++){
if(menormask & (1LL << i)){
cout << i + 1 << " ";
}
}
cout << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |