Pagini recente » Cod sursa (job #1443053) | Istoria paginii runda/captainbobulous/clasament | Cod sursa (job #1892076) | Cod sursa (job #1654048) | Cod sursa (job #1279164)
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int N;
vector<pair<int,int> > Pct;
vector<pair< pair<int,int>, pair<int,int> > > dr;
#define A first
#define B second
#define C first
#define D second
#define x first
#define y second
void read()
{
scanf("%d",&N);
int x,y;
for(int i = 1; i <= N; ++i)
{
scanf("%d%d",&x,&y);
Pct.push_back(make_pair(x,y));
}
}
class cmp{
public:
bool operator()(const pair< pair<int,int>, pair<int,int> > &S1,
const pair< pair<int,int>, pair<int,int> > &S2) const
{
return (1LL*S1.B.y - 1LL*S1.A.y)*(1LL*S2.D.x - 1LL*S2.C.x) < (1LL*S2.D.y - 1LL*S2.C.y)*(1LL*S1.B.x - 1LL*S1.A.x);
}
};
bool egal( pair< pair<int,int>, pair<int,int> > S1,
pair< pair<int,int>, pair<int,int> > S2)
{
return (1LL*S1.B.y - 1LL*S1.A.y)*(1LL*S2.D.x - 1LL*S2.C.x) == (1LL*S2.D.y - 1LL*S2.C.y)*(1LL*S1.B.x - 1LL*S1.A.x);
}
void solve()
{
for(int i = 0; i < N; ++i)
for(int j = 0; j < i; ++j)
dr.push_back(make_pair(Pct[i],Pct[j]));
sort(dr.begin(),dr.end(),cmp());
int crt = 0,sol = 0;
for(int i = 1; i < dr.size(); ++i)
if(egal(dr[i],dr[i-1]))
{
++crt;
sol += crt;
}
else
crt = 0;
printf("%d\n",sol);
}
int main()
{
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
read();
solve();
return 0;
}