-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJava-Arraylist.java
48 lines (40 loc) · 1.21 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
39
40
41
42
43
44
45
46
47
48
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
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. */
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<ArrayList<Integer>> a = new ArrayList<>();
for(int i=0;i<n;i++)
{
int d = sc.nextInt();
ArrayList<Integer> arr = new ArrayList<>();
for(int j=0;j<d;j++)
{
arr.add(sc.nextInt());
}
a.add(arr);
}
int q = sc.nextInt();
int[][] xy = new int[q][2];
int x, y;
for(int i=0;i<q;i++)
{
//xy[i][0] = sc.nextInt();
//xy[i][1] = sc.nextInt();
x = sc.nextInt();
y = sc.nextInt();
try
{
System.out.println(a.get(x-1).get(y-1));
}catch(IndexOutOfBoundsException e)
{
System.out.println("ERROR!");
}
}
}
}