We need to initialize a vector with its size before accessing its elements using indexes. Below is a snippet of part of the code mentioned in this tutorial.
vector < pair <int, int> > pairs; // vector of pairsint a, b;for (i = 0; i < n; i++) {cin >> pairs[i].first >> pairs[i].second;}
This will throw a run time error. We have to initialize the size of the pairs as shown below.
vector < pair <int, int> > pairs(n); // vector of pairsint a, b;for (i = 0; i < n; i++) {cin >> pairs[i].first >> pairs[i].second;}
Please correct it. This is also mentioned in the topcoder tutorial.
Also, if you don't want to define its size during it...