Pagini recente » Cod sursa (job #2077041) | Cod sursa (job #2006378) | Cod sursa (job #127630) | Profil LuBoNI | Cod sursa (job #411231)
Cod sursa(job #411231)
# include <fstream>
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# define PI 3.14159265
# define EPS 0.0001
using namespace std;
struct pct {
float x, y;
friend bool operator < (const pct &a, const pct &b)
{
if(a.x+EPS<b.x || (a.x-b.x>-EPS && a.x-b.x<EPS && a.y+EPS<b.y))
return 1;
return 0;
}
};
vector<pct>v;
int n, sol;
void read ()
{
ifstream fin ("patrate3.in");
pct p;
fin>>n;
for (int i=1;i<=n;i++)
{
fin>>p.x>>p.y;
v.push_back(p);
}
}
void solve ()
{
pct p1, p2, p;
float dx, dy;
for (int i=0;i<n;i++)
for (int j=i+1;j<n;j++)
{
p.x=(v[i].x+v[j].x)/2;
p.y=(v[i].y+v[j].y)/2;
dx=fabs(p.x-v[i].x);
dy=fabs(p.y-v[i].y);
if (v[i].y+EPS<v[j].y)
{
p1.x=p.x+dy;
p1.y=p.y-dx;
p2.x=p.x-dy;
p2.y=p.y+dx;
}
else
{
p1.x=p.x-dy;
p1.y=p.y-dx;
p2.x=p.x+dy;
p2.y=p.y+dx;
}
if (binary_search(v.begin(), v.end(), p1))
if (binary_search(v.begin(), v.end(), p2))
sol++;
}
}
int main ()
{
read();
sort(v.begin(), v.end());
solve ();
ofstream fout ("patrate3.out");
fout<<sol/2;
return 0;
}