-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1043.cpp
More file actions
55 lines (51 loc) · 1.11 KB
/
1043.cpp
File metadata and controls
55 lines (51 loc) · 1.11 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
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
using namespace std;
int n,m;
int person[55];
int knowPerson;
vector<int> v[55];
int answer;
set<int> s;
int main(){
cin>>n>>m;
cin>>knowPerson;
for(int i=1; i<=knowPerson; i++){
int temp; cin>>temp;
s.insert(temp);
}
for(int i=1; i<=m; i++){
int temp; cin>>temp;
for(int j=1; j<=temp; j++){
int p; cin>>p;
v[i].push_back(p);
}
}
while(1){
int flag = 1;
for(int i=1; i<=m; i++){
for(int j=0; j<v[i].size(); j++){
if(s.find(v[i][j]) != s.end()){
for(int k=0; k<v[i].size(); k++){
s.insert(v[i][k]);
flag=0;
}
v[i].clear();
break;
}
}
}
if(flag==1) break;
}
int result = m;
for(int i=1; i<=m; i++){
if(v[i].size()==0) result--;
}
cout<<result<<endl;
return 0;
}