Pagini recente » Cod sursa (job #2461697) | Cod sursa (job #2506841) | Cod sursa (job #3225450) | Cod sursa (job #693264) | Cod sursa (job #3277957)
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define pb push_back
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pqq priority_queue
#define mpp map<int, int>
using namespace std;
const int dim = 1e3 + 55;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
map<int, vector<int> >hasu;
ll ox, oy, n;
struct el
{
ll x, y, idx;
bool operator<(const el&ob) const
{
return x < ob.x;
}
} v[dim];
ll sol;
map<long double, int>hasudoi;
int32_t main(int argc, char * argv[])
{
fin >> n;
for(int i = 1; i <= n; ++i)
{
fin >> v[i].x >> v[i].y;
v[i].idx = i;
}
for(int i = 1; i <= n; ++i) // retinem pantele oricaror 2 perechi de puncte
{
for(int j = i + 1; j <= n; ++j)
{
if(v[i].x == v[j].x)
{
oy++;
continue;
}
if(v[i].y == v[j].y)
{
ox++;
continue;
}
int dify = (v[i].y - v[j].y);
int difx = (v[i].x - v[j].x);
hasudoi[(double)dify / difx]++;
}
}
sol = sol + ox * (ox - 1) / 2 + oy * (oy - 1) / 2;
for(auto it = hasudoi.begin(); it != hasudoi.end(); it++)
{
sol = sol + it->second * (it->second - 1) / 2;
}
fout << sol;
}