-
Notifications
You must be signed in to change notification settings - Fork 0
/
289C.cpp
33 lines (32 loc) · 811 Bytes
/
289C.cpp
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
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m; cin >> n >> m;
vector<vector<int>> a(m, vector<int>(0));
vector<int> ans(n + 1, 0);
int a_ij;
for(int i = 0; i < m; i++) {
int c; cin >> c;
for(int j = 0; j < c; j++) {
cin >> a_ij;
a.at(i).push_back(a_ij);
}
}
int sum = 0;
for(int s = 0; s < (1<<m); s++) {
for(int i = 0; i < m; i++){
if((s >> i) & 1){
for(int j = 0; j < a.at(i).size(); j++){
ans.at(a.at(i).at(j)) = 1;
}
}
}
int check = 0;
for(int i = 0; i < n + 1; i++){
check+=ans.at(i);
ans.at(i) = 0;
}
sum += (check == n);
}
cout << sum << endl;
}