Variable Sized Arrays

  • + 0 comments

    `int main(){

    int n,q,k,i,j,b,pb;
    cin>>n>>q;
    vector<vector<int>> num(n);
    
    for(b = 0;b<n;b++) {
     cin>>k;
     num[b].resize(k);
    
     for(int a = 0; a<k;a++){
         cin>>num[b][a];
    
    }
    }
    
    
    for(int c = 0;c<q;c++){
    cin>>i>>j;`` 
    
    int TO = (i<n && j< num[i].size())?num[i][j]:0;
    
    cout<<TO<<endl;
    
    }
    
    return 0;
    

    }