-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathI065.java
More file actions
38 lines (36 loc) · 1.22 KB
/
I065.java
File metadata and controls
38 lines (36 loc) · 1.22 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
package levelB;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class I065 {
public static void main(String[] args) throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int N=Integer.parseInt(br.readLine());
int[] couples=new int[100000];
String[] str;int a,b;
for(int i=0;i<N;i++){
str=br.readLine().split(" ");
a=Integer.parseInt(str[0]);
b=Integer.parseInt(str[1]);
couples[a]=b;
couples[b]=a;
}
int M=Integer.parseInt(br.readLine());
int[] check=new int[100000];
String[] s=br.readLine().split(" ");
for(int i=0;i<M;i++)
check[Integer.parseInt(s[i])]=1;
ArrayList<Integer> list=new ArrayList<>();
for(int i=0;i<100000;i++){
if(check[i]!=0)
if(check[couples[i]]==0)
list.add(i);
}
System.out.println(list.size());
for(int i=0;i<list.size();i++){
if(i!=0)
System.out.print(" ");
System.out.printf("%05d",list.get(i));
}
}
}