Pagini recente » Cod sursa (job #518359) | Cod sursa (job #1949210)
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n, s;
long long x, y, xf, yf;
vector <long long> drum;
struct cadran{
long long x, y;
};
vector <cadran> c[5];
bool sortare (cadran a, cadran b)
{
return a.x < b.x;
}
void trans (int p)
{
for (int i=0; i<c[p].size(); i++){
int pp = 0;
for (int j=0; j<drum.size() && pp == 0; j++){
if (c[p][i].y >= drum[j]){
pp = 1;
drum [j] = c[p][i].y;
}
}
if (pp == 0){
drum.push_back (c[p][i].y);
}
}
s += drum.size();
drum.clear();
}
int main ()
{
freopen ("pachete.in", "r", stdin);
freopen ("pachete.out", "w", stdout);
scanf ("%d %d %d", &n, &xf, &yf);
for (int i=1; i<=n; i++){
scanf ("%d %d", &x, &y);
if (x >= xf){
if (y >= yf){
c[1].push_back ({x,y});
}
else{
y = yf - y + yf;
c[2].push_back ({x,y});
}
}
else{
if (y >= yf){
x = xf - x + xf;
c[3].push_back ({x,y});
}
else{
x = xf - x + xf;
y = yf - y + yf;
c[4].push_back ({x,y});
}
}
}
for (int i=1; i<=4; i++){
sort (c[i].begin(), c[i].end(), sortare);
trans (i);
}
printf ("%d", s);
return 0;
}