Pagini recente » Cod sursa (job #2783013) | Cod sursa (job #618059) | Monitorul de evaluare | Profil Mexicanu69 | Cod sursa (job #2780076)
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream INPUT("rays.in");
ofstream OUTPUT("rays.out");
struct linie
{
double up;
double down;
};
int N;
int Nr1;
int Nr;
double X;
double Y1;
double Y2;
vector<linie> LeftLines;
vector<linie> RightLines;
void pewpew( int &Nr, vector<linie> &Lines)
{
linie Last = *begin(Lines);
Nr++;
for(auto &itr:Lines)
if( itr.up >= Last.down )
Last.down = max( Last.down, itr.down);
else
{
Nr++;
Last = itr;
}
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
INPUT >> N;
while( N-- )
{
INPUT >> X >> Y1 >> Y2;
if(Y1 > Y2)
swap(Y1,Y2);
if( X < 0 )
LeftLines.push_back( { -1 * Y2 / X, -1 * Y1 / X} );
else
RightLines.push_back( { Y2 / X, Y1 / X} );
}
sort( begin(LeftLines), end(LeftLines), [](linie A, linie B)->bool{ return (A.up == B.up)? (A.down > B.down) : (A.up > B.up);});
sort( begin(RightLines), end(RightLines), [](linie A, linie B)->bool{ return (A.up == B.up)? (A.down > B.down) : (A.up > B.up);});
if( LeftLines.size() )
pewpew( Nr, LeftLines);
if( RightLines.size() )
pewpew( Nr, RightLines);
OUTPUT << Nr;
return 0;
}