Skip to content

Instantly share code, notes, and snippets.

@abranhe
Last active September 26, 2018 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abranhe/4af7d717706966e8132256a7870e4a49 to your computer and use it in GitHub Desktop.
Save abranhe/4af7d717706966e8132256a7870e4a49 to your computer and use it in GitHub Desktop.
Variable Sized Arrays Hackerrank
// See question: https://hackerrank-challenge-pdfs.s3.amazonaws.com/14507-variable-sized-arrays-English?AWSAccessKeyId=AKIAJ4WZFDFQTZRGO3QA&Expires=1537933597&Signature=hih3xrYn04RUlnsFKRVP1%2BFTgWA%3D&response-content-disposition=inline%3B%20filename%3Dvariable-sized-arrays-English.pdf&response-content-type=application%2Fpdf
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n, q;
cin >> n >> q;
vector<vector<int>> v(n);
for (int i = 0; i < n; i++)
{
int k;
cin >> k;
v[i].resize(k);
for (int j = 0; j < k; j++) {
cin >> v[i][j];
}
}
for (int num = 0; num < q; num++) {
int i, j;
cin >> i >> j;
cout << v[i][j] << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment