Cod sursa(job #2352095)

Utilizator niculaandreiNicula Andrei Bogdan niculaandrei Data 22 februarie 2019 22:41:41
Problema Pachete Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.85 kb
#include <bits/stdc++.h>

using namespace std;

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

vector <pair <int, int> > I, II, III, IV;
int N, Ox, Oy, x, y;

int Sol(vector <pair <int, int> > v)
{
    int k = 1, N = v.end() - v.begin();
    if (N == 0)
        return 0;
    sort(v.begin(), v.end());
    for (int i = 1; i < N; i++)
        if (v[i].second < v[i - 1].second)
            k++;
    return k;
}

int main()
{
    fin >> N >> Ox >> Oy;
    while (N--)
    {
        fin >> x >> y;
        x -= Ox;
        y -= Oy;
        if (x > 0 && y > 0) I.push_back({x, y});
        else if (x < 0 && y > 0) II.push_back({-x, y});
        else if (x < 0 && y < 0) III.push_back({-x, -y});
        else if (x > 0 && y < 0) IV.push_back({x, -y});
    }
    fout << Sol(I) + Sol(II) + Sol(III) + Sol(IV);
    return 0;
}