I am solving the variable-sized array problem on hackerrank (https://www.hackerrank.com/challenges/variable-sized-arrays/problem)
I thought of this solution:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n ,q, k, i, j, a[10000][10000];
cin>>n;
cin>>q;
for (int w = 0; w<n; w++)
{
cin>>k;
for (int x=0; x<k; x++)
{
cin>>a[w][x];
}
}
for(int e=0; e<q; e++)
{
cin>>i>>j;
cout <<a[i][j]<<"\n";
}
return 0;
}
It is working for 3 cases but for others, it is giving "Segmentation fault" error. I can't think of anything wrong with this code. How do I solve this?