Hey guys i want to implement a priority queue which contains entries of type 'node'. The code is as follows....
struct node
{
int a;
int b;
};
bool cmp(const node& A,const node& B)
{
return (A.a<B.a) || (A.a==B.a && A.b>B.b);
}
/// main function starts
priority_queue<node,vector<node>, cmp> Y;
But i am not able to compile with error... "type/value mismatch at argument 3 in template parameter list for 'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue"... Can anyone help me out...








The third template parameter of
priority_queueexpects a type (_functor_), not a function. Rather than doing it this way, it's easier to define the comparison operator inside the struct, thenpriority_queuewill see it automatically:struct node { int a; int b; bool operator <(const node& other) const { return (a<other.a) || (a==other.a && b>other.b); } }; . . . priority_queue<node> Y;If you still want to use the functor way, then you should define the functor class:
struct node { int a; int b; }; struct cmp { bool operator ()(const node& A,const node& B) const { return (A.a<B.a) || (A.a==B.a && A.b>B.b); } }; . . . priority_queue<node,vector<node>, cmp> Y;excellent... thanks a lot.. Can i get ur facebook id or email id so that i can be in touch with u ... :)
There is a contact option on CodeForces too (send message to user on profile page):P
i have done this but nobody replies :(