Pagini recente » Cod sursa (job #478502) | Cod sursa (job #636949) | Cod sursa (job #912582) | Cod sursa (job #722806) | Cod sursa (job #1661054)
#include<bits/stdc++.h>
using namespace std;
ifstream in("rays.in");
ofstream out("rays.out");
struct sgm{
long long x, y1, y2;
};
int n, ans;
vector<sgm> vd,vs;
sgm aux;
bool cmp(sgm a, sgm b){
return (a.y2*b.x < a.x*b.y2);
}
void exec(vector<sgm> &v)
{
sort(v.begin(),v.end(),cmp);
if(!v.empty())
{
int x = v[0].x;
int y = v[0].y2;
++ans;
for(int i = 1; i<v.size(); i++)
{
if(y*v[i].x < x*v[i].y1)
{
++ans;
x=v[i].x;
y=v[i].y2;
}
}
}
}
int main()
{
int player_unu=0;
in>>n;
for (int i = 1; i<=n; i++)
{
in>>aux.x>>aux.y1>>aux.y2;
if (aux.y1>aux.y2)
swap(aux.y1, aux.y2);
if (aux.x>0)
{
vd.push_back(aux);
}
else
{
aux.x *= -1;
vs.push_back(aux);
}
}
exec(vd);
exec(vs);
out<<ans<<'\n';
return 0;
}