Pagini recente » Cod sursa (job #2963894) | Cod sursa (job #3225477) | Cod sursa (job #1063714) | Cod sursa (job #3040806) | Cod sursa (job #1525752)
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
vector<pair<int,int> > V[4];
int nr,x,y,ox,oy,n,i;
inline void Solve(int z)
{
if(V[z].empty()) return;
sort(V[z].begin(),V[z].end());
set<int> MySet;
set<int> :: iterator it;
MySet.clear();
MySet.insert(V[z][0].second);
for(int i=1;i<V[z].size();++i)
{
it=MySet.upper_bound(V[z][i].second);
if(it!=MySet.begin()) MySet.erase(--it);
MySet.insert(V[z][i].second);
}
nr+=MySet.size();
}
int main()
{
freopen("pachete.in","r",stdin);
freopen("pachete.out","w",stdout);
scanf("%d%d%d",&n,&ox,&oy);
for(i=1;i<=n;++i)
{
scanf("%d%d",&x,&y);
x-=ox;y-=oy;
if(x>0 && y>0) V[0].push_back({x,y});
else if(x<0 && y>0) V[1].push_back({-x,y});
else if(x>0 && y<0) V[2].push_back({x,-y});
else if(x<0 && y<0) V[3].push_back({-x,-y});
}
Solve(0);
Solve(1);
Solve(2);
Solve(3);
printf("%d\n",nr);
return 0;
}