제출 #1289673

#제출 시각아이디문제언어결과실행 시간메모리
1289673azradudukalayNorela (info1cup18_norela)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector<bitset<105>> eq(n);
    for (int i = 0; i < n; i++) {
        eq[i].set();
    }
    vector<vector<int>> spells(m);
    for (int i = 0; i < m; i++) {
        int q;
        cin >> q;
        spells[i].resize(q);
        for (int j = 0; j < q; j++) {
            cin >> spells[i][j];
            spells[i][j]--;
            eq[spells[i][j]][i] = eq[spells[i][j]][i] ^ 1;
        }
    }
    vector<int> used;
    for (int col = 0; col < m; col++) {
        int pivot = -1;
        for (int row = 0; row < n; row++) {
            if (eq[row][col] && eq[row][105-1]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        used.push_back(col + 1);
        for (int row = 0; row < n; row++) {
            if (row != pivot && eq[row][col]) {
                eq[row] ^= eq[pivot];
            }
        }
    }
    bool possible = true;
    for (int i = 0; i < n; i++) {
        if (eq[i][105-1]) {
            possible = false;
            break;
        }
    }
    if (!possible) {
        cout << "0\n";
    } else {
        cout << used.size() << "\n";
        for (int x : used) {
            cout << x << " ";
        }
        cout << "\n";
    }
    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...