-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
36 lines (29 loc) · 986 Bytes
/
Solution.java
File metadata and controls
36 lines (29 loc) · 986 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
34
35
36
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Solution {
private static final Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();
sc.nextLine();
List<List<Integer>> lists = new ArrayList<>();
for (int i = 0; i < n; i++) {
int items = sc.nextInt();
lists.add(new ArrayList<>());
for (int j = 0; j < items; j++) {
lists.get(i).add(sc.nextInt());
}
sc.nextLine();
}
int q = sc.nextInt();
sc.nextLine();
for (int i = 0; i < q; i++) {
int x = sc.nextInt() - 1;
int y = sc.nextInt() - 1;
if (x < 0 || x >= lists.size() || y < 0 || y >= lists.get(x).size()) System.out.println("ERROR!");
else System.out.println(lists.get(x).get(y));
sc.nextLine();
}
sc.close();
}
}