-
Notifications
You must be signed in to change notification settings - Fork 1
/
Solution.java
37 lines (31 loc) · 1.15 KB
/
Solution.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
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) {
Scanner scanner = new Scanner(System.in);
int listOfListsSize = scanner.nextInt();
List<List<Integer>> listOfLists = new ArrayList<>(listOfListsSize);
for(int i = 0; i < listOfListsSize; i++) {
int listSize = scanner.nextInt();
List<Integer> list = new ArrayList<>(listSize);
for (int j = 0; j < listSize; j++) {
list.add(scanner.nextInt());
}
listOfLists.add(list);
}
int queries = scanner.nextInt();
for(int i = 0; i < queries; i++){
int listIndex = scanner.nextInt();
int innerListIndex = scanner.nextInt();
if(listIndex > listOfLists.size() || innerListIndex > listOfLists.get(listIndex - 1 ).size())
System.out.println("ERROR!");
else {
int result = listOfLists.get(listIndex - 1).get(innerListIndex - 1);
System.out.println(result);
}
}
}
}