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;
int main(){
int n , m;
cin >> n >> m;
long long M = (1LL << n) - 1;
vector<long long> v(m);
for(int i = 0;i < m;i ++){
int x;
cin >> x;
while(x--){
int y;
cin >> y;
--y;
v[i] |= (1LL << y);
}
}
vector<pair<long long , int>> u;
u.emplace_back(make_pair(0LL , 0));
for(int i = 0;i < m;i ++){
vector<pair<long long , int>> e;
for(auto [x , mask] : u){
e.emplace_back(make_pair(x ^ v[i] , mask | (1 << i)));
}
for(auto [x , mask] : e){
u.emplace_back(make_pair(x , mask));
}
}
int best_mask = (1 << (m + 1)) - 1;
for(auto [x , mask] : u){
long long e = (~x & M);
int o = best_mask ^ mask;
if(e == 0){
int bit = __lg(o & -o);
if((mask >> bit & 1) || (best_mask & mask) == mask || (__builtin_popcount(mask) < __builtin_popcount(best_mask))){
best_mask = mask;
}
}
}
cout << __builtin_popcount(best_mask) << endl;
for(int i = 0;i < m;i ++){
if(best_mask >> i & 1){
cout << i + 1 << " ";
}
}
cout << endl;
}
# | 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... |