Cod sursa(job #1788533)

Utilizator daniel.grosuDaniel Grosu daniel.grosu Data 26 octombrie 2016 04:43:12
Problema Trapez Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.12 kb
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#define y second
#define x first
#define lsb(x) (x&-x)
#define pb push_back
#define l(x) x<<1
#define r(x) (x<<1)|1
#define non(x) ( (x) > N? (x) - N : (x) + N)
#define y second
const int MOD=1000000007; //LOL
const int MAXM=210*210;
const int NMAX=4400;
const int HP=73;
const int SQRT=350;
using namespace std;
const double eps=1e-5;
const double PI=acos(-1.0);
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLD;
typedef vector<int> VI;
const int m6[]={1, -1, 1, 1, -1, -1};
const int dx[]={0, 1, 0, -1};
const int dy[]={1, 0, -1, 0};

int n;
PII A[1066];
map<PII, int> M;

int main()
{

	freopen("trapez.in", "r", stdin);
	freopen("trapez.out", "w", stdout);
	cout<<setprecision(10)<<fixed;
	ios_base::sync_with_stdio(0);

	
	cin>>n;
	for(int i=1; i<=n; ++i)
	{
		cin>>A[i].x>>A[i].y;
	}
	for(int i=1; i<=n; ++i)
	{
		for(int j=i+1; j<=n; ++j)
			M[{abs(A[i].x - A[j].x), abs(A[i].y - A[j].y)}]++;
	}
	
	int rs=0;
	for(auto i: M)
	{
		rs+=(i.second*(i.second-1))/2;
	}
	cout<<rs<<"\n";
	
	return 0;
}