-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy path057.cpp
More file actions
61 lines (61 loc) · 1.09 KB
/
057.cpp
File metadata and controls
61 lines (61 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <vector>
#include <iostream>
using namespace std;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<vector<int> > D(N, vector<int>(M, 0));
for (int i = 0; i < N; ++i) {
int t, x;
cin >> t;
for (int j = 0; j < t; ++j) {
cin >> x;
D[i][--x] = 1;
}
}
vector<int> S(M);
for (int i = 0; i < M; ++i) {
cin >> S[i];
}
int pos = 0;
for (int i = 0; i < M; ++i) {
bool found = false;
for (int j = pos; j < N; ++j) {
if (D[j][i] == 1) {
if (j != pos) {
swap(D[j], D[pos]);
}
found = true;
break;
}
}
if (found) {
for (int j = 0; j < N; ++j) {
if (j != pos && D[j][i] == 1) {
for (int k = i; k < M; ++k) {
D[j][k] ^= D[pos][k];
}
}
}
if (S[i] == 1) {
for (int j = i; j < M; ++j) {
S[j] ^= D[pos][j];
}
}
++pos;
}
}
if (S == vector<int>(M, 0)) {
int ans = 1;
for (int i = pos; i < N; ++i) {
ans = ans * 2 % 998244353;
}
cout << ans << endl;
}
else {
cout << 0 << endl;
}
return 0;
}