Variable Sized Arrays

  • + 0 comments
    #include <iostream>
    #include <vector>
    using namespace std;
    //matrix problem  :X
    int main() {
        int n, q;
        cin >> n >> q;
        vector<vector<int>> arr(n);
    
        for (int i = 0; i < n; i++) {
            int k; cin >> k;
            arr[i].resize(k);
            for (int j = 0; j < k; j++) cin >> arr[i][j];
        }
    
        while (q--) {
            int x, y; cin >> x >> y;
            cout << arr[x][y] << "\n";
        }
    }