Pagini recente » Cod sursa (job #1061437) | Cod sursa (job #1144782) | Cod sursa (job #863983) | Cod sursa (job #1688992) | Cod sursa (job #593173)
Cod sursa(job #593173)
# include <algorithm>
# include <cstdio>
# include <cmath>
const char *FIN = "rays.in", *FOU = "rays.out" ;
const int MAX = 200005 ;
struct vector {
double x, y ;
} ;
vector A[MAX], B[MAX] ;
int N ;
bool operator < ( const vector& lhs , const vector& rhs ) {
if ( lhs.x == rhs.x )
return lhs.y < rhs.y;
return lhs.x < rhs.y;
}
int solve (vector *V) {
int sol = 1 ;
std :: sort (V + 1, V + (int) V[0].x + 1) ;
double min = V[1].x ;
for (int i = 2; i <= V[0].x; ++i) {
if (min < V[i].y) {
min = V[i].x, ++sol ;
}
}
return sol ;
}
int main (void) {
freopen (FIN, "r", stdin) ;
scanf ("%d", &N) ;
for (int i = 1, x, y1, y2; i <= N; ++i) {
scanf ("%d %d %d", &x, &y1, &y2) ;
double X = atan2 (y1, abs (x)), Y = atan2 (y2, abs (x)) ;
if (X < Y) std :: swap (X, Y) ;
(x < 0 ? (A[ (int) ++A[0].x ].x = X, A[ (int) A[0].x ].y = Y) : (B[ (int) ++B[0].x ].x = X, B[ (int) B[0].x ].y = Y)) ;
}
fprintf (fopen (FOU, "w"), "%d", solve (A) + solve (B)) ;
}