You are viewing a single comment's thread. Return to all comments →
Mine is below. Yeah, the trick and grist of this one here is figuring out the 'nested' variable-sized array
int main() { int n, q; cin >> n >> q; //NOTE: C++'s variable-sized array: vector vector<vector<int>> a; for (int i = 0; i < n; i++){ int k; cin >> k; vector<int> vect_j; for (int j = 0; j < k; j++){ int val; cin >> val; vect_j.push_back(val); } a.push_back(vect_j); } for (int i = 0; i < q; i++){ int vect_id, id; cin >> vect_id >> id; cout << a.at(vect_id).at(id) << "\n"; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Variable Sized Arrays
You are viewing a single comment's thread. Return to all comments →
Mine is below. Yeah, the trick and grist of this one here is figuring out the 'nested' variable-sized array