Pagini recente » Cod sursa (job #2612283) | Cod sursa (job #1326519) | Cod sursa (job #1160346) | Cod sursa (job #3163301) | Cod sursa (job #2541512)
#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 = v[0].first - 1;
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;
if (_x > 0) {
unghi1 = atan2(_y1, _x);
unghi2 = atan2(_y2, _x);
if (unghi2 < unghi1)
swap(unghi2, unghi1);
v1.push_back({unghi1, unghi2});
} else {
unghi1 = atan2(_y1, - _x);
unghi2 = atan2(_y2, - _x);
if (unghi2 < unghi1)
swap(unghi2, unghi1);
v2.push_back({unghi1, unghi2});
}
}
solve(v1);
solve(v2);
fout << ans;
return 0;
}