Skip to content

Instantly share code, notes, and snippets.

@manish-manghwani
Created December 19, 2020 08:34
Show Gist options
  • Select an option

  • Save manish-manghwani/e267bd0a4c72a36afc2e72955e886e06 to your computer and use it in GitHub Desktop.

Select an option

Save manish-manghwani/e267bd0a4c72a36afc2e72955e886e06 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.util.*;
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>> ip = new ArrayList<ArrayList<Integer>>(n);
for (int i=0; i<n; i++) {
int d = sc.nextInt();
ArrayList<Integer> innerList = new ArrayList<>();
for(int j=0; j<d ; j++) {
innerList.add(sc.nextInt());
}
ip.add(innerList);
}
int q = sc.nextInt();
for (int i=0; i<q; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
try {
System.out.println(ip.get(x-1).get(y-1));
}catch(Exception err) {
System.out.println("ERROR!");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment