Pagini recente » Cod sursa (job #1536251) | Cod sursa (job #1522014) | Cod sursa (job #3189635) | Cod sursa (job #331186) | Cod sursa (job #2625877)
#include <bits/stdc++.h>
#include <fstream>
#define limit 1e-5
using namespace std;
fstream fin("patrate3.in", ios::in);
fstream fout("patrate3.out", ios::out);
struct point {
double x, y;
bool operator < (const point& other) const {
return (abs(x - other.x) < limit ? y < other.y - limit : x < other.x - limit);
}
};
point *pointsVec;
set <point> s;
bool check(int a, int b) {
double xm = (pointsVec[a].x + pointsVec[b].x) / 2;
double ym = (pointsVec[a].y + pointsVec[b].y) / 2;
double delta_y = abs(ym - pointsVec[a].y);
double delta_x = abs(xm - pointsVec[a].x);
if (pointsVec[a].y < pointsVec[b].y)
delta_x *= -1;
point new_x, new_y;
new_x.x = xm - delta_y;
new_x.y = ym - delta_x;
new_y.x = xm + delta_y;
new_y.y = ym + delta_x;
if (s.find(new_x) != s.end() && s.find(new_y) != s.end())
return true;
return false;
}
int main() {
int n; fin >> n;
pointsVec = new point[n];
for (int i = 1; i <= n; i++)
{
fin >> pointsVec[i].x >> pointsVec[i].y;
s.insert(pointsVec[i]);
}
sort(pointsVec + 1, pointsVec + 1 + n);
int ans = 0;
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++)
ans += check(i, j);
fout << ans / 2;
}