Pagini recente » Cod sursa (job #2300461) | Cod sursa (job #2295442) | Cod sursa (job #1562882) | Cod sursa (job #971358) | Cod sursa (job #1390772)
#include <fstream>
#include <algorithm>
#include <vector>
#include <cstring>
#define x first
#define y second
#define LL long long
using namespace std;
ifstream fin ("pachete.in");
ofstream fout ("pachete.out");
LL N, Ox, Oy, maxy, maxx, maxim_X, maxim_Y, sol;
vector < pair < LL, LL > > C[5];
LL Afla_Numarul_Minim_De_Drumuri(vector < pair < LL, LL > > V)
{
LL nr = 0, val = 0;
bool fr[V.size() + 10];
memset (fr, 0, sizeof(fr));
while (nr < V.size())
{
LL xx = 0, yy = 0;
for (LL i = 0; i < V.size(); i++)
{
if (!fr[i] && V[i].y >= yy)
{
xx = V[i].x;
yy = max (yy, V[i].y);
fr[i] = 1;
nr++;
}
}
val++;
}
return val;
}
int main()
{
fin >> N;
fin >> Ox >> Oy;
for (LL xx, yy, i = 1; i <= N; i++)
{
fin >> xx >> yy;
xx -= Ox;
yy -= Oy;
if (xx > 0 && yy > 0) C[1].push_back(make_pair(xx, yy));
if (xx > 0 && yy < 0) C[2].push_back(make_pair(xx, -yy));
if (xx < 0 && yy < 0) C[3].push_back(make_pair(-xx, -yy));
if (xx < 0 && yy > 0) C[4].push_back(make_pair(-xx, yy));
if (xx == 0) {
maxy = max (maxy, yy);
continue;
}
if (yy == 0) {
maxx = max (maxx, xx);
continue;
}
if (xx > maxim_X) maxim_X = xx;
if (yy > maxim_Y) maxim_Y = yy;
}
for (LL i = 1; i <= 4; i++)
{
sort (C[i].begin(), C[i].end());
sol += Afla_Numarul_Minim_De_Drumuri(C[i]);
}
if (maxim_X < maxx) sol++;
if (maxim_Y < maxy) sol++;
fout << sol << '\n';
fout.close();
return 0;
}