답안 #637243

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
637243 2022-09-01T06:51:13 Z tvladm2009 Norela (info1cup18_norela) C++14
0 / 100
3 ms 3412 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[1 << MAX_M];
vector<int> mn;

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) {
            vector<int> used;
            for (int bit = 0; bit < m; bit++) {
                if (mask & (1 << bit)) {
                    used.push_back(bit + 1);
                }
            }
            if (mn.size() == 0 || used < mn) {
                mn = used;
            }
        }
    }
    for (int it : mn) {
        cout << it << " ";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3412 KB Output isn't correct
2 Halted 0 ms 0 KB -