ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

To admins: binary_function<member, member, bool>
Posted by VorobeY1326 11 Oct 2009 14:17
Hello!
I have tryed to solve 1022 on C++:

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

struct member
{
        int latency;
        int number;
        vector<int>child;
        member() {latency=0; child.resize(0);}
};

struct member_less : public binary_function<member, member, bool>
{
        bool operator()(const member& m1, const member& m2) const
        { return m1.latency < m2.latency; };
};

int main()
{
        int numb_of_members;
        cin >> numb_of_members;
        vector<member>mosk(numb_of_members);
        for (int i=0;i<numb_of_members;i++)
        {
                mosk[i].number=i;
                int buf;
                cin >> buf;
                while(buf!=0)
                {
                        mosk[i].child.push_back(buf);
                        cin >> buf;
                }
        }
        bool stop=false;
        while(stop==false)
        {
                stop=true;
                for (int i=0;i<numb_of_members;i++)
                {
                        for(int j=0;j<mosk[i].child.size();j++)
                        {
                                if (mosk[mosk[i].child[j]].latency <= mosk[i].latency)
                                {mosk[mosk[i].child[j]].latency = mosk[i].latency+1; stop=false;}
                        }
                }
        }
        sort(mosk.begin(),mosk.end(),member_less());
        for (int i=0;i<numb_of_members;i++)
        cout << mosk[i].number << " ";
        return 0;
}

But I have got errors:

685a5f5c-5454-4df3-be25-6c467c9fdfd1
685a5f5c-5454-4df3-be25-6c467c9fdfd1(14): error: binary_function is not a template
  struct member_less : public binary_function<member, member, bool>
                              ^

685a5f5c-5454-4df3-be25-6c467c9fdfd1(14): error: not a class or struct name
  struct member_less : public binary_function<member, member, bool>

Why? On my computer this programm works well!