forked from sknsht/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
31 lines (26 loc) · 836 Bytes
/
Solution.java
File metadata and controls
31 lines (26 loc) · 836 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
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
ArrayList<ArrayList<Integer>> rows = new ArrayList<>();
int n = in.nextInt();
for (int i = 0; i < n; i++) {
int m = in.nextInt();
ArrayList<Integer> row = new ArrayList<>();
for (int j = 0; j < m; j++) {
row.add(in.nextInt());
}
rows.add(row);
}
n = in.nextInt();
for (int i = 0; i < n; i++) {
int x = in.nextInt();
int y = in.nextInt();
try {
System.out.println(rows.get(x - 1).get(y - 1));
} catch (Exception e) {
System.out.println("ERROR!");
}
}
}
}