Pagini recente » Cod sursa (job #2949131) | Cod sursa (job #2824347) | Cod sursa (job #2887353) | Cod sursa (job #3275466) | Cod sursa (job #2619488)
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
ifstream f ("patrate3.in");
ofstream g ("patrate3.out");
const double eps=0.0001;
const int nmax = 1e3 + 3;
int n, ans;
pair <double, double> v[nmax], a, b;
bool cmp(pair <double, double> a, pair <double, double> b)
{
return (a.x <= b.x - eps || a.x < b.x + eps && a.y <= b.y - eps);
}
int main()
{
f >> n;
for(int i = 1; i <= n; ++i) f >> v[i].x >> v[i].y;
sort(v + 1, v + n + 1);
for(int i = 1; i <= n; ++i)
{
for(int j = i + 1; j <= n; ++j)
{
if(v[j].x > v[i].x && v[j].y >= v[i].y)
{
double dx = v[j].x - v[i].x;
double dy = v[j].y - v[i].y;
a = make_pair(v[i].x - dy, v[i].y + dx);
b = make_pair(v[j].x - dy, v[j].y + dx);
ans += (binary_search(v + 1,v + n + 1, b, cmp) && binary_search(v + 1,v + n + 1, a, cmp));
}
}
}
g << ans;
return 0;
}