-
Notifications
You must be signed in to change notification settings - Fork 280
Expand file tree
/
Copy pathVariable-Sized-array.cpp
More file actions
35 lines (31 loc) · 935 Bytes
/
Copy pathVariable-Sized-array.cpp
File metadata and controls
35 lines (31 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
/*
Contributor:Ankit Bhujeja
Problem statement: https://www.hackerrank.com/challenges/variable-sized-arrays/problem?isFullScreen=true
*/
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n,queries;
cin>>n>>q;
vector<vector<int>> arr(n); //Creating a main vector contains reference tpo first elemnt of vector containg in each element
for(int i=0;i<n;i++)
int size;
cin>>size;
vector<int> iarr(size,0);
for(int j=0;j<size;j++){ // Creating sub vectors for each element of main vector
cin>>iarr[j];
}
arr[i]=iarr;
}
for(int i=0;i<queries;i++){ // Handling the queries
int j,k;
cin>>j>>k;
cout<<arr[j][k]<<endl;
}
return 0;
}