Pagini recente » Cod sursa (job #1834880) | Cod sursa (job #3156492) | Cod sursa (job #1902058) | Cod sursa (job #754039) | Cod sursa (job #2076325)
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
struct punct
{
int x,y1,y2;
};
const double eps=1.e-14;
bool cmp1(punct a,punct b)
{
return ((double)a.y2/(double)a.x)-((double)b.y2/(double)b.x)<=-eps;
}
bool cmp2(punct a,punct b)
{
return ((double)a.y2/(double)a.x)-((double)b.y2/(double)b.x)>=eps;
}
punct v1[200001],v2[200001];
int main()
{
freopen("rays.in","r",stdin);
freopen("rays.out","w",stdout);
int n,i,x,y1,y2,nr1=0,nr2=0;
scanf("%d",&n);
for(i=1;i<=n;++i)
{
scanf("%d%d%d",&x,&y1,&y2);
if(x>0)
{
nr1++;
v1[nr1].x=x;
if(y1<=y2)
{
v1[nr1].y1=y1;
v1[nr1].y2=y2;
}
else
{
v1[nr1].y1=y2;
v1[nr1].y2=y1;
}
}
else
{
nr2++;
v2[nr2].x=x;
if(y1<=y2)
{
v2[nr2].y1=y1;
v2[nr2].y2=y2;
}
else
{
v2[nr2].y1=y2;
v2[nr2].y2=y1;
}
}
}
sort(v1+1,v1+nr1+1,cmp1);
sort(v2+1,v2+nr2+1,cmp2);
int poz=1;
int sol=1;
for(i=1;i<=nr1;++i)
{
if((double)v1[poz].y2/(double)v1[poz].x-(double)v1[i].y1/(double)v1[i].x<=-eps)
{
sol++;
poz=i;
}
}
poz=1;
sol++;
for(i=1;i<=nr2;++i)
{
if((double)v2[poz].y2/(double)v2[poz].x-(double)v2[i].y1/(double)v2[i].x>=eps)
{
sol++;
poz=i;
}
}
printf("%d\n",sol);
return 0;
}