-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA 1056 - Determine Line.java
45 lines (38 loc) · 1.2 KB
/
A 1056 - Determine Line.java
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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] data, data2;
int n = input.nextInt();
data = new int[input.nextInt()];
for (int i = 0; i < data.length; i++) {
data[i] = input.nextInt();
}
boolean isTrue;
for (int i = 0; i < n - 1; i++) {
data2 = new int[input.nextInt()];
for (int j = 0; j < data2.length; j++) {
data2[j] = input.nextInt();
}
for (int j = 0; j < data.length; j++) {
isTrue = false;
if (data[j] != 0) {
for (int k = 0; k < data2.length; k++) {
if (data[j] == data2[k]) {
isTrue = true;
break;
}
}
if (isTrue == false) {
data[j] = 0;
}
}
}
}
for (int i = 0; i < data.length; i++) {
if (data[i] != 0) {
System.out.print(data[i] + " ");
}
}
}
}