Skip to content

Instantly share code, notes, and snippets.

@suryansh011
Created January 1, 2022 11:42
Show Gist options
  • Save suryansh011/e149075b2f56288f678eb17f70773429 to your computer and use it in GitHub Desktop.
Save suryansh011/e149075b2f56288f678eb17f70773429 to your computer and use it in GitHub Desktop.
Variable Sized Arrays
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n{}, q{};
cin >> n >> q;
vector <vector<int>> a;
for(int i = 0; i < n; ++i) {
a.push_back(vector<int>());
int k{};
cin >> k;
for(int j = 0; j < k; ++j) {
int m;
cin >> m;
a[i].push_back(m);
}
}
for(int i = 0; i < q; ++i) {
int p{}, q{};
cin >> p >> q;
cout << a.at(p).at(q) << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment