Pagini recente » Cod sursa (job #1614620) | Cod sursa (job #1647586) | Cod sursa (job #780545) | Cod sursa (job #2210833) | Cod sursa (job #2540718)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cstring>
#define NMAX 200000
using namespace std;
int n, sol, umap[NMAX+10], val = 1;
struct punct
{ long long cx, cy;
int nr, c;
};
vector <punct> v[5];
inline bool mycmp(punct a, punct b)
{ if(a.cy * b.cx <= a.cx * b.cy) return 1;
return 0;
}
void solve(int p)
{ sort(v[p].begin(), v[p].end(), mycmp);
for(int i=0; i<v[p].size(); i++)
{ if(!v[p][i].c) umap[v[p][i].nr] = val;
else if(umap[v[p][i].nr] == val)
{ val++;
sol++;
}
}
}
int main()
{
ifstream cin("rays.in");
ofstream cout("rays.out");
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i=1; i<=n; i++)
{ long long x, y1, y2;
cin >> x >> y1 >> y2;
punct a1, a2;
a1.cx = a2.cx = x;
a1.cy = y1;
a2.cy = y2;
a1.nr = a2.nr = i;
if(y1 < y2)
{ a1.c = 0;
a2.c = 1;
if(x > 0) v[1].push_back(a1), v[1].push_back(a2);
else
{ a1.cx = a2.cx = -x;
v[2].push_back(a1);
v[2].push_back(a2);
}
}
else
{ a1.c = 1;
a2.c = 0;
if(x > 0) v[1].push_back(a2), v[1].push_back(a1);
else
{ a1.cx = a2.cx = -x;
v[2].push_back(a2);
v[2].push_back(a1);
}
}
}
solve(1);
solve(2);
cout << sol << '\n';
return 0;
}