Pagini recente » Cod sursa (job #2506226) | Cod sursa (job #682190) | Cod sursa (job #2684886) | Cod sursa (job #3233468) | Cod sursa (job #2736439)
#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<double, double> > poz, neg;
inline int solve(vector<pair<double, double> > V) {
sort(V.begin(), V.end());
double m = V[0].first - 1;
int ans = 0;
for(int i = 0; i < V.size(); ++i)
if(m < V[i].first) ++ans, m = V[i].second;
else m = min(m, V[i].second);
return ans;
}
int main()
{
freopen("rays.in", "r", stdin);
freopen("rays.out", "w", stdout);
scanf("%d", &n);
for(int i = 1; i <= n; ++i) {
int x, y1, y2, vx;
scanf("%d%d%d", &x, &y1, &y2),
vx = (x > 0 ? x : -x);
double unghi1 = atan2(y1, vx), unghi2 = atan2(y2, vx);
if(unghi1 > unghi2) swap(unghi1, unghi2);
if(x > 0) poz.push_back({unghi1, unghi2});
else neg.push_back({unghi1, unghi2});
}
printf("%d", solve(poz) + solve(neg));
return 0;
}