Last active
September 26, 2018 02:52
-
-
Save abranhe/4af7d717706966e8132256a7870e4a49 to your computer and use it in GitHub Desktop.
Variable Sized Arrays Hackerrank
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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