Pagini recente » Cod sursa (job #2160079) | Cod sursa (job #2628780) | Cod sursa (job #203911) | Cod sursa (job #173993) | Cod sursa (job #2406880)
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const double PI=2.0*acos(0.0);
const double eps=4e-17;
double unghi(int x, int y)
{
double rad=1.0*atan2(1.0*y,1.0*x);
// if(rad<0) rad+=2 * PI;
return rad * 180 / PI;
}
struct mem
{
double unghi;
bool tip;
int ind;
};
mem v[400005];
int poz[200005];
bool cmp(mem a, mem b)
{
if(fabs(a.unghi-b.unghi)<eps) return a.tip>b.tip;
return a.unghi-b.unghi<-eps;
}
const int sz=1<<16;
int pz=sz-1;
char buffer[sz];
char ad()
{
++pz;
if(pz==sz)
{
pz=0;
fread(buffer,1,sz,stdin);
}
return buffer[pz];
}
int form()
{
char ch=ad();
while(!(ch=='-'||(ch>='0'&&ch<='9')))
ch=ad();
int nr1=0,s1=1;
if(ch=='-'){s1=-1;ch=ad();}
while(ch>='0'&&ch<='9')
{
if(!(ch>='0'&&ch<='9'))
{
if(s1==-1&&nr1==0) continue;
break;
}
nr1=nr1*10+ch-'0';
ch=ad();
}
return nr1*s1;
}
int main()
{
freopen("rays.in","r",stdin);
freopen("rays.out","w",stdout);
int h,n,x,y1,y2,cnt=0,cnta=0,act=0,gloante=0;
double u1,u2;
n=form();
for(register int i=1;i<=n;i++)
{
x=form();y1=form();y2=form();
h=2*i;
v[h-1].unghi=unghi(x,y1);
v[h].unghi=unghi(x,y2);
if(v[h].unghi-v[h-1].unghi<-eps) swap(v[h-1].unghi,v[h].unghi);
v[h-1].ind=v[h].ind=i;
v[h-1].tip=1;
v[h].tip=0;
}
sort(v+1,v+2*n+1,cmp);
for(register int i=1;i<=2*n;i++)
{
if(v[i].tip==1) cnt++;
else if(poz[v[i].ind]>act) cnt--;
poz[v[i].ind]=act+1;
if(cnt<cnta)
{
gloante++;
act++;
cnt=0;
}
cnta=cnt;
}
printf("%d",gloante);
return 0;
}