What is problem with my code for variable size multidimensional array .How to fix this problem. My code is not passing all test cases.Can anyone help me to fix it.This is question from hackerrank challenge.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,q;
cin>>n;
cin>>q;
int *arr[n];
for(int i=0;i<n;i++)
{
int x;
cin>>x;
int b[x];
for(int j=0;j<x;j++)
{
cin>>b[j];
}
arr[i]=b;
}
while(q--)
{
int i,e;
cin>>i>>e;
cout<<arr[i][e]<<endl;
}
return 0;
}