We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n, q;
cin >> n >> q; // number of arrays and number of queries
vector<vector<int>> arr(n);
// input arrays
for (int i = 0; i < n; i++) {
int k;
cin >> k; // size of this array
arr[i].resize(k);
for (int j = 0; j < k; j++) {
cin >> arr[i][j];
}
}
// answer queries
for (int i = 0; i < q; i++) {
int M, N;
cin >> M >> N;
cout << arr[M][N] << endl;
}
return 0;
}
Cookie support is required to access HackerRank
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 →
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n, q; cin >> n >> q; // number of arrays and number of queries
}