Submission #637239

#TimeUsernameProblemLanguageResultExecution timeMemory
637239tvladm2009Norela (info1cup18_norela)C++14
0 / 100
2 ms3288 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long long ld; const int MAX_N = 60; const int MAX_M = 24; ll spells[MAX_N + 1], cards[1ll << MAX_M]; int lg2[1 << MAX_M]; int n, m; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= m; i++) { int q; cin >> q; while (q--) { int x; cin >> x; x--; spells[i] |= (1ll << x); } } for (int i = 2; i < (1ll << m); i++) { lg2[i] = lg2[i >> 1] + 1; } for (int mask = 1; mask < (1 << m); mask++) { int bit = lg2[(mask & -mask)]; cards[mask] = (cards[mask ^ (1ll << bit)] ^ spells[bit + 1]); } int answer = (1 << 30); for (int mask = 0; mask < (1 << m); mask++) { if (cards[mask] == (1ll << n) - 1) { answer = min(answer, __builtin_popcountll(mask)); } } cout << answer << "\n"; for (int mask = 0; mask < (1 << m); mask++) { if (cards[mask] == (1ll << n) - 1) { for (int bit = 0; bit < m; bit++) { if (mask & (1 << bit)) { cout << bit + 1 << " "; } } return 0; } } 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...