제출 #1289567

#제출 시각아이디문제언어결과실행 시간메모리
1289567opituNorela (info1cup18_norela)C++20
0 / 100
11 ms416 KiB
#include <bits/stdc++.h>
#define int long long
#define POP __builtin_popcount
#define iamaperson int main() {\
preprocess();\
int t = 1; while (t--) solve();\
}
using namespace std;

void preprocess() {} // just in case!!!!1

void solve() {
    int n, m; cin >> n >> m;
    vector<int> mgc(m);
    for (int i = 0; i < m; ++i) {
        int q; cin >> q;
        for (int _ = 0; _ < q; ++_) {
            int x; cin >> x;
            mgc[i] |= 1LL<<(x-1);
        }
    }
    vector<int> pot;
    for (int i = 0; i < 1LL<<m; ++i) {
        int x = 0;
        for (int j = 0; j < m; ++j) if (i&(1<<(m-1-j))) {
            x ^= mgc[j];
        }
        if (x == (1LL<<n)-1) pot.push_back(i);
    }
    int ans = *min_element(pot.begin(), pot.end(), [&](const int &a, const int &b){ return POP(a) < POP(b) ? 1 : a > b; });
    cout << POP(ans) << '\n';
    for (int j = 0; j < m; ++j) if (ans&(1<<(m-1-j))) cout << 1+j << ' ';
}

#undef int

iamaperson
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...