개요[ | ]
- HR자바 Java Arraylist
Java
Copy
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> lines = new ArrayList<ArrayList>();
for(int i=0; i<n; i++) {
int d = sc.nextInt();
ArrayList<Integer> line = new ArrayList<Integer>();
for(int j=0; j<d; j++) line.add(sc.nextInt());
lines.add(line);
}
int q = sc.nextInt();
for(int i=0; i<q; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
try {
System.out.println( lines.get(x-1).get(y-1) );
}
catch(IndexOutOfBoundsException e) {
System.out.println("ERROR!");
}
}
}
}
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.