Pagini recente » Cod sursa (job #986579) | Cod sursa (job #2714340)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("rays.in");
ofstream fout("rays.out");
vector<pair<double, double> > poz, neg;
int solve(vector<pair<double, double> > vec){
sort(vec.begin(), vec.end());
int rez = 0;
double mn = vec[0].first - 1;
for(int i = 0; i < (int)vec.size(); ++i){
if(vec[i].first > mn){
++rez;
mn = vec[i].second;
}
else mn = min(mn, vec[i].second);
}
return rez;
}
int main()
{
int n;
fin >> n;
for(int i = 1; i <= n; ++i)
{
int x, y1, y2;
fin >> x >> y1 >> y2;
int xx = (x > 0 ? x : -x);
double ang1 = atan2(y1, xx);
double ang2 = atan2(y2, xx);
if(ang1 > ang2)
swap(ang1, ang2);
if(x > 0)
poz.push_back({ang1, ang2});
else neg.push_back({ang1, ang2});
}
fout << solve(poz) + solve(neg) << '\n';
return 0;
}