Variable Sized Arrays

Sort by

recency

|

1438 Discussions

|

  • + 0 comments

    using namespace std;

    int main() { int n, q; cin >> n >> q;

    vector<std::vector<int>> arr(n);
    
    for (int i = 0; i < n; i++) {
        int size;
        cin >> size;
    
        arr[i].resize(size);
    
        for (int j = 0; j < size; j++) {
            cin >> arr[i][j];
        }
    }
    
    for (int k = 0; k < q; k++) {
        int i, j;
        cin >> i >> j;
    
        cout << arr[i][j] << endl;
    }
    
    return 0;
    

    }

  • + 0 comments
    int n;
    cin>>n;
    int q;
    cin>>q;
    vector<vector<int>> arr(n);
    for(int i=0;i<n;i++)
    {
        int size;
        cin>>size;
        for(int j=0;j<size;j++)
        {
            int num;
            cin>>num;
            arr[i].push_back(num);
        }
    }
    for(int i=0;i<q;i++)
    {
        int a,b;
        cin>>a>>b;
        cout<<arr[a][b]<<endl;
    }
    
  • + 1 comment

    this has to be the worst worded question ever written.

  • + 0 comments

    the question is not clear.

  • + 0 comments

    int n,q; cin>>n>>q; vector> arr(n); for (int i=0;i>size; arr[i].resize(size); for (int j=0; j>arr[i][j]; } } while (q--) { int x,y; cin>>x>>y; cout<