Submission #637230

# Submission time Handle Problem Language Result Execution time Memory
637230 2022-09-01T04:46:18 Z tvladm2009 Norela (info1cup18_norela) C++14
0 / 100
4 ms 2516 KB
#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[100];
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 time Memory Grader output
1 Runtime error 4 ms 2516 KB Execution killed with signal 7
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 2516 KB Execution killed with signal 7
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 2516 KB Execution killed with signal 7
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 2516 KB Execution killed with signal 7
2 Halted 0 ms 0 KB -