Submission #1062094

#TimeUsernameProblemLanguageResultExecution timeMemory
1062094peraNorela (info1cup18_norela)C++17
0 / 100
9 ms8384 KiB
#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; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...