用一维数组保存二维矩阵:

import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] v = new int[n*m];
        for(int i = 0; i < n*m; ++i) v[i] = sc.nextInt();
        int p = sc.nextInt(), q = sc.nextInt();
        System.out.println(v[(p - 1)*m + (q - 1)]);
    }
}