-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patharrayList.java
More file actions
29 lines (25 loc) · 942 Bytes
/
arrayList.java
File metadata and controls
29 lines (25 loc) · 942 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
import java.util.*;
public class 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 sc = new Scanner(System.in);
int n = sc.nextInt();
String s = sc.nextLine();
ArrayList<ArrayList<String>> a = new ArrayList<ArrayList<String>>(n);
for (int i = 0; i < n; i++) {
s = sc.nextLine();
a.add(i, new ArrayList<String>(Arrays.asList(s.split("\\s"))));
}
sc.close();
int m = sc.nextInt();
for (int i = 0; i < m; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
if (x <= a.size() && y < a.get(x-1).size() && y >= 0) {
System.out.println(a.get(x-1).get(y));
} else {
System.out.println("ERROR!");
}
}
}
}