Pagini recente » Cod sursa (job #1711176) | Cod sursa (job #2274171) | Cod sursa (job #1795232) | Cod sursa (job #1194892) | Cod sursa (job #2541546)
#include <fstream>
#include <cmath>
#include <algorithm>
#define ld long double
using namespace std;
ifstream cin ("rays.in");
ofstream cout ("rays.out");
int n, x, y, z;
ld angle1, angle2;
vector <pair <ld, ld>> poz, neg;
int solve(vector <pair <ld, ld>> v) {
int ans = 0;
long double mn = v[0].first - 1;
sort(v.begin(), v.end());
for(auto &i : v) {
if(i.first > mn) {
ans++;
mn = i.second;
} else
mn = min(mn, i.second);
}
return ans;
}
int main() {
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> x >> y >> z;
int x2 = abs(x);
angle1 = atan2(y, x2);
angle2 = atan2(z, x2);
if(angle2 < angle1)
swap(angle1, angle2);
if(x >= 0)
poz.push_back({angle1, angle2});
else
neg.push_back({angle1, angle2});
}
cout << solve(poz) + solve(neg);
return 0;
}