#include using namespace std; int f(int nn, int qq, vector> arrays, vector> queries) { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n, q; vector> v; ///////////////// //cin >> n >> q; n = nn, q = qq; // read arrays for (int i = 0; i < n; i++) // iterate over arrays { int num_elem; ///////////////// //cin >> num_elem; num_elem = arrays[i][0]; v.push_back(vector{}); for (int j = 0; j < num_elem; j++) { int val; ////////////// //cin >> val; val = arrays[i][j+1]; v[i].push_back(val); } } // read queries, print results for (int i = 0; i < q; i++) { int vector_num, index_to_read; ////////////////////////////////////// // cin >> vector_num >> index_to_read; vector_num = queries[i][0]; index_to_read = queries[i][1]; cout << v[vector_num][index_to_read] << endl; } for (int j = 0; j < n ; j++ ) { for (auto& i: v[j]) { cout << i << " "; } cout << endl; } return 0; } int main(void) { // Sample input // 2 2 // 3 1 5 4 // 5 1 2 8 9 3 // 0 1 // 1 3 // The first line contains two space-separated integers denoting the respective values of (the // number of variable-length arrays) and (the number of queries). // Each line of the subsequent lines contains a space-separated sequence in the format k a[i]0 // a[i]1 … a[i]k-1 describing the k-element array located at a[i]. // Each of the subsequent lines contains two space-separated integers describing the respective // values of (an index in array ) and (an index in the array referenced by a[i]) tuple>, vector>> testCase = { 2, 2, {{3,1,5,4},{5,1,2,8,9,3}}, {{0,1},{1,3}} }; f(get<0>(testCase), get<1>(testCase), get<2>(testCase), get<3>(testCase)); return 0; }