Skip to content

Instantly share code, notes, and snippets.

@roxsula
Created February 21, 2019 21:24
Show Gist options
  • Save roxsula/5c779b0999c5c5540067be9662a5f965 to your computer and use it in GitHub Desktop.
Save roxsula/5c779b0999c5c5540067be9662a5f965 to your computer and use it in GitHub Desktop.
Vector of Vectors in C++
#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>> arr(n);
for(int i=0; i<n; i++)
{
int k = 0;
cin >> k;
arr[i].resize(k);
for(int j=0; j<k; j++) cin >> arr[i][j];
}
for(int m=0; m<q; m++)
{
int a = 0;
int b = 0;
cin >> a >> b;
cout << arr[a][b] << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment