Submission #915808

#TimeUsernameProblemLanguageResultExecution timeMemory
915808andrei_iorgulescuNorela (info1cup18_norela)C++14
100 / 100
133 ms432 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n,m,a[30]; int maskmare; vector<int>sol,cur; int curnum; void bkt(int pos) { if (pos == m + 1) { if (curnum == maskmare and (cur.size() < sol.size() or sol.size() == 0)) sol = cur; } else { curnum ^= a[pos]; cur.push_back(pos); bkt(pos + 1); curnum ^= a[pos]; cur.pop_back(); bkt(pos + 1); } } signed main() { cin >> n >> m; maskmare = (1ll << n) - 1; for (int i = 1; i <= m; i++) { int cate; cin >> cate; for (int j = 1; j <= cate; j++) { int x; cin >> x; a[i] += (1ll << (x - 1)); } } bkt(1); cout << sol.size() << '\n'; for (auto it : sol) cout << it << ' '; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...