Cod sursa(job #2312748)

Utilizator Alex_BubBuburuzan Alexandru Alex_Bub Data 5 ianuarie 2019 14:29:07
Problema Pachete Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.09 kb
#include <fstream>
#include <algorithm>
#include <vector>

using namespace std;

ifstream fin("pachete.in");
ofstream fout("pachete.out");

struct str{int x, y;};

int N, x0, y0, x, y;

vector <str> C[5];

///C2 + C1
///---0+++
///C3 - C4

inline bool Comp(str a, str b) {
    return a.x > b.x;
}

int Solve(int k)
{
    sort(C[k].begin(), C[k].end(), Comp);

    int maxi = 0, Sol = 0;

    for(int i = 0; i < (int)C[k].size(); i++)
    {
        if(C[k][i].y > maxi)
            maxi = C[k][i].y, Sol++;
    }

    return Sol;
}

int main()
{
    fin >> N >> x0 >> y0;

    for(int i = 0; i < N; i++) {
        fin >> x >> y;

        x -= x0, y -= y0; ///reper 0,0

        if(x > 0 && y > 0)
            C[1].push_back({x, y});

        if(x < 0 && y > 0)
            C[2].push_back({-x, y});

        if(x < 0 && y < 0)
            C[3].push_back({-x, -y});

        if(x > 0 && y < 0)
            C[4].push_back({x, -y});
    }

    fout << Solve(1) + Solve(2) + Solve(3) + Solve(4) << '\n';

    fin.close();
    fout.close();

    return 0;
}