Hello , can any one please explain how to get the value of key of type pair<int,int> .
i.e map<pair<int,int>,int> ? I am getting an error
And also can anyone please explain when to use map and unordered_map ?
Thanks in advance
Hello , can any one please explain how to get the value of key of type pair<int,int> .
i.e map<pair<int,int>,int> ? I am getting an error
And also can anyone please explain when to use map and unordered_map ?
Thanks in advance
you need to define a hash function in unordered_map when you use pairs
you can access the value like this-
map<pair<int,int>,int>mp;
cout<<mp[{x,y}];
where {x,y} is the pair
or use auto
Yeah , i was using unordered_map . Thanks btw !!
You might also want to go through this article. It’s also gonna help if you don’t want to get hacked in CodeForces competitions. In fact, quite a few participants (including me) got their asses handed to them in this contest, in this problem for using unordered_map
/ unordered_set
’s default hash function.
That was a really cool article; thanks!
Thanks a lot bro !