Pagini recente » Profil M@2Te4i | Statistici Iacob Alexandru (Alexandru_Iacob) | Profil M@2Te4i | Cod sursa (job #1293589) | Cod sursa (job #2002374)
#include <fstream>
#include <algorithm>
#define VAL 1005
#define X 1000000
#define F first
#define S second
#define LL long long
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
int N, ans, i, j;
LL H, L;
double L1, L2;
pair <LL, LL> pct, P1, P2;
pair <LL, LL> P[VAL];
bool Binary_Search(pair <LL, LL> pct)
{
int be=1, en=N;
int mid;
while (be<=en)
{
mid=(be+en) / 2;
if (P[mid].F==pct.F && P[mid].S==pct.S)
return true;
else
{
if (P[mid].F<pct.F || (P[mid].F==pct.F && P[mid].S<pct.S))
be=mid+1;
if (P[mid].F>pct.F || (P[mid].F==pct.F && P[mid].S>pct.S))
en=mid-1;
}
}
return false;
}
int main()
{
fin >> N;
for (i=1; i<=N; i++)
{
fin >> L1 >> L2;
P[i].F=X*L1;
P[i].S=X*L2;
}
sort(P+1, P+N+1);
for (i=1; i<N; i++)
{
for (j=i+1; j<=N; j++)
{
pct.F=(P[i].F+P[j].F) / 2;
pct.S=(P[i].S+P[j].S) / 2;
H=pct.F-P[i].F;
L=pct.S-P[i].S;
if (H<0)
H=-H;
if (L<0)
L=-L;
if (P[i].S<P[j].S)
{
P1.F=pct.F+L;
P1.S=pct.S-H;
P2.F=pct.F-L;
P2.S=pct.S+H;
}
else
{
P1.F=pct.F-L;
P1.S=pct.S-H;
P2.F=pct.F+L;
P2.S=pct.S+H;
}
if (Binary_Search(P1)==true && Binary_Search(P2)==true)
ans++;
}
}
fout << ans / 2 << '\n';
fin.close();
fout.close();
return 0;
}