vector<pair<int, int> > adj[105];
I am assigning the adjacent vertex of u : v and the weight of edge uv : w by adj[u].push_back(make_pair(v,w)). Now how to access the elements( first and second of pair). Plz expain this in detail as I did not get much useful on net.
adj[u].first; adj[u].second;
Deleted
because adj[u] itself is a vector of pairs so this must work adj[u][v].first and adj[u][v].second
Note that:vector<pair<int,int> > v[100] is like saying vector<vector<pair<int,int> > > v(100);
Can u plz elaborate as adj[u][v].first is giving me garbage value. Can u tell me what adj[u][v].first and adj[u][v].second should produce according to the input pattern specified in my blog.
adj[u][v].first is the (v+1)th (zero-based) vertex connected to u.And adj[u][v].second is the weight of the edge uv.
http://ideone.com/P8muPO
Here, adj[u] is a vector of pairs.
So to get weight of an edge uv, you need to iterate through this vector, find v and get the weight.
using C++11