-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1800.java
More file actions
33 lines (27 loc) · 925 Bytes
/
1800.java
File metadata and controls
33 lines (27 loc) · 925 Bytes
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
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args) {
try (Scanner scanner = new Scanner(System.in)) {
int Q = scanner.nextInt();
int E = scanner.nextInt();
Set<Integer> recent = new HashSet<>();
StringBuilder output = new StringBuilder();
for (int i = 0; i < E; i++) {
int id = scanner.nextInt();
recent.add(id);
}
for (int i = 0; i < Q; i++) {
int id = scanner.nextInt();
if (recent.contains(id)) {
output.append("0\n");
} else {
output.append("1\n");
recent.add(id);
}
}
System.out.print(output.toString());
}
}
}