-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBj1764.java
More file actions
41 lines (31 loc) · 1.01 KB
/
Bj1764.java
File metadata and controls
41 lines (31 loc) · 1.01 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
package string;
import java.io.*;
import java.util.*;
class Bj1764 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
Set<String> dj = new HashSet<>();
for (int i = 0; i < N; i++) {
dj.add(br.readLine());
}
List<String> dbj = new ArrayList<>();
for (int i = 0; i < M; i++) {
String name = br.readLine();
if (dj.contains(name)) {
dbj.add(name);
}
}
Collections.sort(dbj);
bw.write(dbj.size() + "\n");
for (String name : dbj) {
bw.write(name + "\n");
}
bw.flush();
br.close();
bw.close();
}
}