Pagini recente » Cod sursa (job #2741819) | Cod sursa (job #323312) | Cod sursa (job #287701) | Cod sursa (job #780797) | Cod sursa (job #1743582)
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream cin("rays.in");
ofstream cout("rays.out");
struct Segment {
int x, y1, y2;
};
vector<Segment> a, b;
bool Compare(const Segment &a, const Segment &b) {
return 1LL * a.x * b.y2 > 1LL * b.x * a.y2;
}
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
Segment now;
cin >> now.x >> now.y1 >> now.y2;
if (now.y1 > now.y2)
swap(now.y1, now.y2);
if (now.x > 0)
a.push_back(now);
else {
now.x = -now.x;
b.push_back(now);
}
}
int answer = 0;
sort(a.begin(), a.end(), Compare);
if (a.size() != 0) {
answer++;
int x = a[0].x;
int y = a[0].y2;
for (int i = 1; i < a.size(); i++)
if (1LL * x * a[i].y1 > 1LL * y * a[i].x) {
answer++;
x = a[i].x;
y = a[i].y2;
}
}
sort(b.begin(), b.end(), Compare);
if (b.size() != 0) {
answer++;
int x = b[0].x;
int y = b[0].y2;
for (int i = 1; i < b.size(); i++)
if (1LL * x * b[i].y1 > 1LL * y * b[i].x) {
answer++;
x = b[i].x;
y = b[i].y2;
}
}
cout << answer << "\n";
return 0;
}