Posted on

It’s about C++ vector.

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int n, q;
    cin >> n >> q;
    vector<vector<int>> a;
    for (int i = 0; i < n; i++) {
        vector<int> t;
        int cnt;
        cin >> cnt;
        for(int j = 0; j < cnt; j++) {
            int tmp;
            cin >> tmp;
            t.push_back(tmp);
        }
        a.push_back(t);
    }

    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << a[x][y];
        if(i != q - 1) cout << "\n";
    }
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *