Pagini recente » Cod sursa (job #2032434) | Cod sursa (job #1192075) | Cod sursa (job #732226) | Cod sursa (job #740606) | Cod sursa (job #1153811)
#include <cstdio>
#include <algorithm>
#include <cmath>
#define NMAX 200005
#define eps 0.000001
using namespace std;
struct punct
{
double u;
bool c;
};
punct pp[NMAX << 1]; //pozitive
punct pn[NMAX << 1]; //negative
//double uc; //unghi curent
int n, nr;
int k = -1, l = -1;
void citire();
void solve();
bool cmp(punct a, punct b)
{
return a.u < b.u;
}
int main()
{
freopen("rays.in", "r",stdin);
freopen("rays.out", "w",stdout);
scanf("%d", &n);
citire();
sort(pp,pp+k,cmp);
sort(pn,pn+l,cmp);
solve();
return 0;
}
void citire()
{
int x, y1, y2;
for (int i = 0; i < n; ++i)
{
scanf("%d %d %d",&x, &y1, &y2);
if (y1>y2) swap(y1,y2);
if (x>0)
{
pp[++k].u = (double)y1/x;
pp[k].c = false;
pp[++k].u = (double)y2/x;
pp[k].c = true;
}
else
{
pn[++l].u = (double)y1/x;
pn[l].c = false;
pn[++l].u = (double)y2/x;
pn[l].c = true;
}
}
}
void solve()
{
// pozitive
int i = 1;
while (i < k)
{
while ( pp[i].c == false && i<k)
++i;
while ( fabs(pp[i+1].u - pp[i].u) < eps && i<k)
++i;
if (i==k-1) break;
++nr; ++i;
}
// negative
i = 1;
while (i < l)
{
while ( pn[i].c == false && i<l) ++i;
while ( fabs(pn[i+1].u - pn[i].u) < eps && i<l) ++i;
if (i==l-1) break;
++nr; ++i;
}
printf("%d\n",nr);
}