Cod sursa(job #2659028)

Utilizator Razvan48Capatina Razvan Nicolae Razvan48 Data 15 octombrie 2020 17:48:44
Problema Ubuntzei Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.18 kb
#include <iostream>
#include <queue>

using namespace std;

struct nod
{
    int a;
    int b;
    int c;

    nod (int a, int b, int c)
    {
        this->a = a;
        this->b = b;
        this->c = c;
    }

    bool operator>(const nod &arg) const
    {
        if (this->a > arg.a)
        {
            return true;
        }
        else if (this->a == arg.a)
        {
            if (this->b > arg.b)
            {
                return true;
            }
            else if (this->b == arg.b)
            {
                if (this->c >= arg.c)
                {
                    return true;
                }
                return false;
            }
            return false;
        }
        return false;
    }
};

priority_queue<nod, vector<nod>, greater<nod>>pq;

int main()
{
    pq.push(nod(0, 0, 0));
    pq.push(nod(1, 0, 0));
    pq.push(nod(1, 2, 3));
    pq.push(nod(1, 2, 4));
    pq.push(nod(1, 2, 2));
    pq.push(nod(2, 3, 4));
    pq.push(nod(2, 4, 3));

    while (!pq.empty())
    {
        cout << pq.top().a << ' ' << pq.top().b << ' ' << pq.top().c << '\n';
        pq.pop();
    }
    return 0;
}