-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJava Arraylist.java
38 lines (30 loc) · 1.09 KB
/
Java Arraylist.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
import java.io.*;
import java.util.*;
// Java 8
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
ArrayList<ArrayList< Integer >> arr = new ArrayList<ArrayList< Integer >>();
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for (int n=0 ; n<N ; ++n) {
int D = sc.nextInt();
ArrayList< Integer > a = new ArrayList< Integer >();
for (int d=0 ; d<D ; ++d) {
a.add(sc.nextInt());
}
arr.add(a);
}
int Q = sc.nextInt();
for (int q=0 ; q<Q ; ++q) {
int x = sc.nextInt();
int y = sc.nextInt();
try {
System.out.println(arr.get(x-1).get(y-1));
} catch (Exception e) {
System.out.println("ERROR!");
}
}
}
}
// Have a nice day.