Pagini recente » Cod sursa (job #1298708) | Cod sursa (job #2147264) | Cod sursa (job #2382232) | Cod sursa (job #1381615) | Cod sursa (job #2541498)
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
ifstream fin ("rays.in");
ofstream fout ("rays.out");
int n, _x, _y1, _y2, ans;
double unghi1, unghi2;
vector <pair <double, double> > v1, v2;
void solve(vector <pair <double, double> > v) {
sort (v.begin(), v.end());
double x = -2e9;
for (auto it : v) {
if (it.first > x) {
++ans;
x = it.second;
}
else x = min(x, it.second);
}
}
int main() {
fin >> n;
for (int i = 1; i <= n; ++i) {
fin >> _x >> _y1 >> _y2;
unghi1 = atan2(_y1, _x);
unghi2 = atan2(_y2, _x);
if (unghi2 < unghi1)
swap(unghi2, unghi1);
if (_x > 0) {
v1.push_back({unghi1, unghi2});
} else
v2.push_back({unghi1, unghi2});
}
solve(v1);
solve(v2);
fout << ans;
return 0;
}