-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_Arraylist.java
More file actions
46 lines (39 loc) · 1 KB
/
Java_Arraylist.java
File metadata and controls
46 lines (39 loc) · 1 KB
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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Java_Arraylist {
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 scan=new Scanner(System.in);
int total=scan.nextInt();
ArrayList<ArrayList<Integer>> mainlist=new ArrayList<>();
for(int i=0;i<total;i++)
{
int size=scan.nextInt();
ArrayList<Integer> list=new ArrayList();
for(int j=0;j<size;j++)
{
int item=scan.nextInt();
list.add(item);
}
mainlist.add(list);
}
int totalprint=scan.nextInt();
for(int k=0;k<totalprint;k++)
{
int row=scan.nextInt();
int col=scan.nextInt();
try
{
System.out.println(mainlist.get(row-1).get(col-1));
}
catch(Exception e)
{
System.out.println("ERROR!");
}
}
scan.close();
}
}