Variable Sized Arrays

  • + 0 comments

    My solution:

    include

    using namespace std;

    int main(){ ios::sync_with_stdio(0); cin.tie(0);

    int n, q;
    cin >> n >> q;
    vector<vector<int>> no(n);
    for(int i = 0; i<n; i++){
        int k;
        cin >> k;
        no[i].resize(k);
        for(int j = 0; j<k; j++){
            cin >> no[i][j];
        }
    }
    while(q-->0){
        int x, y;
        cin >> x >> y;
        cout << no[x][y] << '\n';
    }
    
    return 0;
    

    }

    I am not that familiar with pointers actually, so I used vectors instead.

    return 0;
    

    }