Created
December 19, 2020 08:34
-
-
Save manish-manghwani/e267bd0a4c72a36afc2e72955e886e06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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